or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

config-modification.mdcore-management.mdindex.mdtraffic-statistics.mduser-port-management.mdutilities-global-settings.md

user-port-management.mddocs/

0

# User and Port Management

1

2

Multi-user and multi-port management capabilities for V2ray/Xray proxy servers. Enables adding, deleting, and configuring users and port groups with various protocols including VMess, VLESS, Trojan, Shadowsocks, Socks5, and MTProto.

3

4

## Capabilities

5

6

### Port Group Management

7

8

Add and remove port groups with different protocols and configurations.

9

10

```python { .api }

11

def new_port(new_stream=None):

12

"""

13

Add a new port group with specified or interactive protocol selection.

14

15

Parameters:

16

- new_stream (str, optional): Protocol type to add automatically.

17

Supported: 'tcp', 'tcp_http', 'ws', 'h2',

18

'mkcp', 'utp', 'srtp', 'wechat-video',

19

'dtls', 'wireguard', 'quic', 'socks',

20

'mtproto', 'ss', 'vless_tcp', 'vless_tls',

21

'vless_ws', 'vless_reality', 'trojan'

22

23

If new_stream is None, opens interactive menu for protocol selection.

24

Generates random port and creates configuration for selected protocol.

25

Automatically opens firewall ports and restarts service.

26

"""

27

28

def del_port():

29

"""

30

Delete an existing port group interactively.

31

32

Displays list of configured port groups and allows selection

33

for deletion. Removes all associated users and configurations.

34

Updates firewall rules and restarts service.

35

"""

36

```

37

38

### User Management

39

40

Add and remove individual users within existing port groups.

41

42

```python { .api }

43

def new_user():

44

"""

45

Add a new user to an existing port group.

46

47

Interactive process to:

48

1. Select target port group

49

2. Configure user-specific settings (UUID, email, etc.)

50

3. Apply changes and restart service

51

52

Supports all protocol types with appropriate user configurations.

53

"""

54

55

def del_user():

56

"""

57

Delete an existing user from a port group.

58

59

Interactive selection from configured users across all port groups.

60

Preserves port group configuration while removing specific user.

61

"""

62

```

63

64

## User and Group Classes

65

66

### Base User Class

67

68

```python { .api }

69

class User:

70

"""Base class for all user types"""

71

def __init__(self, port, uuid, email, alter_id=0):

72

"""

73

Initialize user with basic parameters.

74

75

Parameters:

76

- port (int): Port number for the user

77

- uuid (str): User UUID

78

- email (str): User email identifier

79

- alter_id (int): VMess AlterID (default: 0)

80

"""

81

82

def user_info(self):

83

"""Return user configuration information"""

84

85

def protocol(self):

86

"""Return protocol type string"""

87

```

88

89

### Protocol-Specific User Classes

90

91

```python { .api }

92

class Vmess(User):

93

"""VMess protocol user management"""

94

def __init__(self, port, uuid, alter_id, email, path=None):

95

"""

96

VMess user with optional WebSocket path.

97

98

Parameters:

99

- path (str, optional): WebSocket path for WS transport

100

"""

101

102

def link_vmess(self):

103

"""Generate VMess connection string"""

104

105

class Vless(User):

106

"""VLESS protocol user management"""

107

def __init__(self, port, uuid, email, flow=None):

108

"""

109

VLESS user with optional XTLS flow.

110

111

Parameters:

112

- flow (str, optional): XTLS flow type

113

"""

114

115

def link_vless(self):

116

"""Generate VLESS connection string"""

117

118

class Trojan(User):

119

"""Trojan protocol user management"""

120

def __init__(self, port, password, email):

121

"""

122

Trojan user with password authentication.

123

124

Parameters:

125

- password (str): Trojan password

126

"""

127

128

def link_trojan(self):

129

"""Generate Trojan connection string"""

130

131

class SS(User):

132

"""Shadowsocks user management"""

133

def __init__(self, port, password, method, email):

134

"""

135

Shadowsocks user configuration.

136

137

Parameters:

138

- password (str): SS password

139

- method (str): Encryption method

140

"""

141

142

class Socks(User):

143

"""Socks5 proxy user management"""

144

def __init__(self, port, username, password, email):

145

"""

146

Socks5 user with authentication.

147

148

Parameters:

149

- username (str): Socks5 username

150

- password (str): Socks5 password

151

"""

152

153

class Mtproto(User):

154

"""MTProto (Telegram) user management"""

155

def __init__(self, port, secret, email):

156

"""

157

MTProto user for Telegram proxy.

158

159

Parameters:

160

- secret (str): MTProto secret

161

"""

162

163

def link_mtproto(self):

164

"""Generate MTProto connection string"""

165

```

166

167

### Group Management

168

169

```python { .api }

170

class Group:

171

"""Port group management with multiple users"""

172

def __init__(self, port, stream_type):

173

"""

174

Initialize port group.

175

176

Parameters:

177

- port (int): Group port number

178

- stream_type (str): Transport protocol type

179

"""

180

181

def add_user(self, user):

182

"""Add user to the group"""

183

184

def del_user(self, user_index):

185

"""Remove user from the group"""

186

187

def group_info(self):

188

"""Display group configuration and user list"""

189

```

190

191

## Dynamic Port Management

192

193

```python { .api }

194

class Dyport:

195

"""Dynamic port range management"""

196

def __init__(self, start_port, end_port):

197

"""

198

Configure dynamic port range.

199

200

Parameters:

201

- start_port (int): Range start port

202

- end_port (int): Range end port

203

"""

204

```

205

206

## Usage Examples

207

208

### Adding Port Groups

209

210

```python

211

from v2ray_util.config_modify.multiple import new_port, new_user

212

213

# Interactive port addition

214

new_port()

215

216

# Add specific protocol with random port

217

new_port('tcp') # TCP protocol

218

new_port('ws') # WebSocket protocol

219

new_port('mkcp') # mKCP protocol

220

new_port('trojan') # Trojan protocol

221

new_port('vless_tcp') # VLESS over TCP

222

new_port('ss') # Shadowsocks

223

```

224

225

### User Management

226

227

```python

228

# Add new user to existing port group

229

new_user()

230

231

# Delete existing user

232

from v2ray_util.config_modify.multiple import del_user, del_port

233

234

del_user() # Remove specific user

235

del_port() # Remove entire port group

236

```

237

238

### Programmatic Group Management

239

240

```python

241

from v2ray_util.util_core.group import Group, Vmess

242

243

# Create port group

244

group = Group(8080, 'tcp')

245

246

# Create and add VMess user

247

user = Vmess(8080, 'uuid-string', 2, 'user@example.com')

248

group.add_user(user)

249

250

# Display group information

251

group.group_info()

252

```

253

254

## Supported Protocols

255

256

### Transport Protocols

257

- **TCP**: Standard TCP transport

258

- **TCP_HTTP**: TCP with HTTP header masquerading

259

- **WebSocket (WS)**: WebSocket transport with custom paths

260

- **HTTP/2 (H2)**: HTTP/2 over TLS (requires domain)

261

- **mKCP**: UDP-based reliable transport with various masquerading:

262

- **UTP**: BitTorrent uTP masquerading

263

- **SRTP**: FaceTime call masquerading

264

- **wechat-video**: WeChat video call masquerading

265

- **DTLS**: DTLS 1.2 masquerading

266

- **wireguard**: WireGuard masquerading

267

- **QUIC**: Quick UDP Internet Connections

268

269

### Proxy Protocols

270

- **VMess**: V2ray's proprietary protocol

271

- **VLESS**: Lightweight version of VMess

272

- **Trojan**: Trojan proxy protocol

273

- **Shadowsocks**: Popular SOCKS5-based proxy

274

- **Socks5**: Standard SOCKS5 proxy

275

- **MTProto**: Telegram proxy protocol

276

277

## Interactive Features

278

279

All user and port management functions provide:

280

- Interactive protocol selection menus

281

- Automatic port generation and conflict detection

282

- Real-time configuration validation

283

- Automatic firewall rule management

284

- Service restart with status verification

285

- Connection string generation for client configuration