-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsmtp-tunnel-listusers
More file actions
70 lines (52 loc) 路 1.95 KB
/
Copy pathsmtp-tunnel-listusers
File metadata and controls
70 lines (52 loc) 路 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
"""
SMTP Tunnel - List Users Script
Shows all configured users.
Version: 1.3.0
"""
import argparse
import os
import sys
# Add current directory to path for imports
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from common import load_users
def main():
parser = argparse.ArgumentParser(
description='List all SMTP Tunnel users',
formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument('--users-file', '-u', default='/etc/smtp-tunnel/users.yaml', help='Users file (default: /etc/smtp-tunnel/users.yaml)')
parser.add_argument('--verbose', '-v', action='store_true', help='Show detailed information')
args = parser.parse_args()
# Get base directory
base_dir = os.path.dirname(os.path.abspath(__file__))
# Load users
users_file = args.users_file
if not os.path.isabs(users_file):
users_file = os.path.join(base_dir, users_file)
users = load_users(users_file)
if not users:
print("No users configured")
print(f"Use smtp-tunnel-adduser to add users")
return 0
print(f"Users ({len(users)}):")
print("-" * 60)
for username, user in sorted(users.items()):
if args.verbose:
print(f"\n {username}:")
print(f" Secret: {user.secret[:8]}...{user.secret[-4:]}")
if user.whitelist:
print(f" Whitelist: {', '.join(user.whitelist)}")
else:
print(f" Whitelist: (any IP)")
print(f" Logging: {'enabled' if user.logging else 'disabled'}")
else:
whitelist_info = f" [{len(user.whitelist)} IPs]" if user.whitelist else ""
logging_info = " [no-log]" if not user.logging else ""
print(f" {username}{whitelist_info}{logging_info}")
if not args.verbose:
print()
print("Use -v for detailed information")
return 0
if __name__ == '__main__':
sys.exit(main())