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

config-modification.mddocs/

0

# Configuration Modification

1

2

Protocol configuration and modification capabilities for V2ray/Xray proxy servers. Provides comprehensive control over transport protocols, TLS settings, Shadowsocks configuration, CDN integration, and core configuration parameters.

3

4

## Capabilities

5

6

### Base Configuration Management

7

8

Fundamental configuration options including ports, UUIDs, AlterID, TCP Fast Open, and dynamic ports.

9

10

```python { .api }

11

def port():

12

"""

13

Modify port configuration for existing groups.

14

15

Interactive selection of port group and new port assignment.

16

Handles port conflict detection and firewall rule updates.

17

Supports both single port and port range modifications.

18

"""

19

20

def new_uuid():

21

"""

22

Generate and assign new UUID to existing users.

23

24

Interactive user selection with automatic UUID generation.

25

Updates configuration and provides new connection strings.

26

"""

27

28

def alterid():

29

"""

30

Modify VMess AlterID for enhanced security.

31

32

Interactive user selection and AlterID value input.

33

Valid range: 0-65535, with 0 recommended for better performance.

34

"""

35

36

def new_email():

37

"""

38

Change user email identifier.

39

40

Interactive user selection and email input with validation.

41

Updates user configuration while preserving other settings.

42

"""

43

44

def tfo():

45

"""

46

Toggle TCP Fast Open (TFO) setting.

47

48

Enables or disables TCP Fast Open for improved connection performance.

49

Applies globally to all TCP-based connections.

50

"""

51

52

def dyn_port():

53

"""

54

Configure dynamic port range for load balancing.

55

56

Interactive configuration of port range (start-end ports).

57

Enables automatic port distribution for high-traffic scenarios.

58

"""

59

```

60

61

### Stream Protocol Configuration

62

63

Modify transport layer protocols and their specific settings.

64

65

```python { .api }

66

class StreamModifier:

67

"""Stream protocol modification and configuration"""

68

69

def __init__(self, group_list):

70

"""

71

Initialize stream modifier with group list.

72

73

Parameters:

74

- group_list (list): List of configured port groups

75

"""

76

77

def modify_stream(self, group, stream_type):

78

"""

79

Modify stream transport protocol for a group.

80

81

Parameters:

82

- group: Target port group

83

- stream_type (str): New stream type

84

85

Supported stream types:

86

- 'tcp': Standard TCP

87

- 'tcp_http': TCP with HTTP masquerading

88

- 'ws': WebSocket

89

- 'h2': HTTP/2 over TLS

90

- 'mkcp': mKCP with header options

91

- 'quic': QUIC protocol

92

"""

93

94

def modify(group=None, sType=None):

95

"""

96

Interactive stream protocol modification.

97

98

Parameters:

99

- group (optional): Specific group to modify

100

- sType (optional): Specific stream type to apply

101

102

If parameters are None, provides interactive selection menus.

103

"""

104

```

105

106

### TLS Configuration

107

108

SSL/TLS certificate management and configuration for secure connections.

109

110

```python { .api }

111

class TLSModifier:

112

"""TLS configuration and certificate management"""

113

114

def __init__(self, group_list):

115

"""

116

Initialize TLS modifier.

117

118

Parameters:

119

- group_list (list): List of configured groups

120

"""

121

122

def modify_tls(self, group):

123

"""

124

Configure TLS settings for a group.

125

126

Parameters:

127

- group: Target port group

128

129

Handles certificate generation, domain configuration,

130

and TLS protocol settings.

131

"""

132

133

def modify():

134

"""

135

Interactive TLS configuration modification.

136

137

Provides options for:

138

- Enable/disable TLS

139

- Domain configuration

140

- Certificate management

141

- TLS version settings

142

"""

143

```

144

145

### Shadowsocks Configuration

146

147

Shadowsocks-specific settings including encryption methods and passwords.

148

149

```python { .api }

150

class SSFactory:

151

"""Shadowsocks configuration factory"""

152

153

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

154

"""

155

Initialize Shadowsocks configuration.

156

157

Parameters:

158

- port (int): SS port number

159

- password (str): SS password

160

- method (str): Encryption method

161

- email (str): User identifier

162

"""

163

164

def create_ss_inbound(self):

165

"""Create Shadowsocks inbound configuration"""

166

167

def create_ss_outbound(self):

168

"""Create Shadowsocks outbound configuration"""

169

170

def modify(alter_type='method'):

171

"""

172

Modify Shadowsocks configuration parameters.

173

174

Parameters:

175

- alter_type (str): Type of modification

176

'method' - Change encryption method

177

'password' - Change password

178

179

Supported encryption methods:

180

- aes-256-gcm, aes-128-gcm

181

- chacha20-poly1305, chacha20-ietf-poly1305

182

- xchacha20-poly1305, xchacha20-ietf-poly1305

183

"""

184

```

185

186

### CDN Configuration

187

188

CloudFlare CDN integration for traffic routing and obfuscation.

189

190

```python { .api }

191

class CDNModifier:

192

"""CDN configuration and management"""

193

194

def __init__(self, group_list):

195

"""

196

Initialize CDN modifier.

197

198

Parameters:

199

- group_list (list): Configured port groups

200

"""

201

202

def set_cdn(self, group, domain):

203

"""

204

Configure CDN settings for a group.

205

206

Parameters:

207

- group: Target port group

208

- domain (str): Domain name for CDN routing

209

210

Configures CloudFlare CDN proxy settings and updates

211

client connection information.

212

"""

213

214

def modify():

215

"""

216

Interactive CDN configuration.

217

218

Provides domain input, CDN enable/disable options,

219

and automatic client configuration updates.

220

"""

221

```

222

223

### Configuration Writers

224

225

Low-level JSON configuration manipulation classes for advanced usage.

226

227

```python { .api }

228

class Writer:

229

"""Base configuration writer for JSON manipulation"""

230

231

def __init__(self, group_tag='A', group_index=0):

232

"""

233

Initialize configuration writer.

234

235

Parameters:

236

- group_tag (str): Group identifier tag

237

- group_index (int): Group index in configuration

238

"""

239

240

def load(self, path):

241

"""

242

Load V2ray configuration from file.

243

244

Parameters:

245

- path (str): Configuration file path

246

247

Returns:

248

dict: Parsed JSON configuration

249

"""

250

251

def load_template(self, template_name):

252

"""

253

Load configuration template.

254

255

Parameters:

256

- template_name (str): Template filename

257

258

Returns:

259

dict: Template configuration

260

"""

261

262

def save(self):

263

"""Save current configuration to file"""

264

265

class StreamWriter(Writer):

266

"""Stream protocol configuration writer"""

267

268

def __init__(self, group_tag, group_index, stream_type=None):

269

"""

270

Initialize stream writer.

271

272

Parameters:

273

- group_tag (str): Group identifier

274

- group_index (int): Group index

275

- stream_type (str, optional): Target stream protocol

276

"""

277

278

def to_mtproto(self, template_json):

279

"""Convert configuration to MTProto protocol"""

280

281

def to_kcp(self, header_type):

282

"""

283

Convert configuration to mKCP protocol.

284

285

Parameters:

286

- header_type (str): Header masquerading type

287

"""

288

289

def write(self, **kw):

290

"""

291

Write stream configuration with specified parameters.

292

293

Supports various stream types: TCP, WebSocket, HTTP/2,

294

mKCP, QUIC, VLESS, Trojan protocols.

295

"""

296

297

class GroupWriter(Writer):

298

"""Port group configuration writer"""

299

300

def __init__(self, group_tag, group_index):

301

"""Initialize group writer"""

302

303

def write_port(self, port):

304

"""Update group port number"""

305

306

def write_ss_password(self, new_password):

307

"""Update Shadowsocks password"""

308

309

def write_ss_method(self, new_method):

310

"""Update Shadowsocks encryption method"""

311

312

def write_dyp(self, status=False, aid='32'):

313

"""Configure dynamic port settings"""

314

315

def write_tls(self, status=False, crt_file=None, key_file=None, domain=None, alpn=None):

316

"""Configure TLS settings for the group"""

317

318

def write_tfo(self, action='del'):

319

"""Configure TCP Fast Open settings"""

320

321

class ClientWriter(Writer):

322

"""Individual client configuration writer"""

323

324

def __init__(self, group_tag='A', group_index=0, client_index=0):

325

"""

326

Initialize client writer.

327

328

Parameters:

329

- group_tag (str): Group identifier

330

- group_index (int): Group index

331

- client_index (int): Client index within group

332

"""

333

334

def write_aid(self, aid=32):

335

"""Update VMess AlterID"""

336

337

def write_uuid(self, new_uuid):

338

"""Update client UUID"""

339

340

def write_email(self, email):

341

"""Update client email identifier"""

342

343

class GlobalWriter(Writer):

344

"""Global configuration writer"""

345

346

def __init__(self, group_list):

347

"""

348

Initialize global writer.

349

350

Parameters:

351

- group_list (list): List of configured groups

352

"""

353

354

def write_ban_bittorrent(self, status=False):

355

"""Configure BitTorrent blocking rules"""

356

357

def write_stats(self, status=False):

358

"""Configure traffic statistics collection"""

359

360

def create_new_port(self, newPort):

361

"""Create new port group configuration"""

362

363

def create_new_user(self, **kw):

364

"""Create new user configuration"""

365

366

def del_user(self, group, client_index):

367

"""Delete user from group"""

368

369

def del_port(self, group):

370

"""Delete entire port group"""

371

```

372

373

## Usage Examples

374

375

### Basic Configuration Changes

376

377

```python

378

from v2ray_util.config_modify import base

379

380

# Change port interactively

381

base.port()

382

383

# Generate new UUID

384

base.new_uuid()

385

386

# Modify AlterID

387

base.alterid()

388

389

# Toggle TCP Fast Open

390

base.tfo()

391

```

392

393

### Stream Protocol Modification

394

395

```python

396

from v2ray_util.config_modify.stream import modify, StreamModifier

397

398

# Interactive stream modification

399

modify()

400

401

# Programmatic stream modification

402

from v2ray_util.util_core.profile import Profile

403

404

profile = Profile()

405

groups = profile.load()

406

modifier = StreamModifier(groups)

407

408

# Change to WebSocket

409

modifier.modify_stream(groups[0], 'ws')

410

```

411

412

### TLS Configuration

413

414

```python

415

from v2ray_util.config_modify.tls import modify, TLSModifier

416

417

# Interactive TLS configuration

418

modify()

419

420

# Programmatic TLS setup

421

profile = Profile()

422

groups = profile.load()

423

tls_modifier = TLSModifier(groups)

424

tls_modifier.modify_tls(groups[0])

425

```

426

427

### Shadowsocks Configuration

428

429

```python

430

from v2ray_util.config_modify.ss import modify

431

432

# Change encryption method

433

modify('method')

434

435

# Change password

436

modify('password')

437

```

438

439

### CDN Setup

440

441

```python

442

from v2ray_util.config_modify.cdn import modify

443

444

# Interactive CDN configuration

445

modify()

446

```

447

448

## Stream Types and Options

449

450

### TCP Options

451

- **Standard TCP**: Direct TCP connection

452

- **HTTP Masquerading**: TCP with HTTP header camouflage

453

454

### WebSocket Options

455

- **Path Configuration**: Custom WebSocket paths

456

- **Headers**: Custom HTTP headers for camouflage

457

458

### mKCP Options

459

- **Header Types**: Various masquerading options

460

- `srtp`: FaceTime call simulation

461

- `utp`: BitTorrent traffic simulation

462

- `wechat-video`: WeChat video call simulation

463

- `dtls`: DTLS 1.2 simulation

464

- `wireguard`: WireGuard VPN simulation

465

- **Congestion Control**: BBR congestion control

466

- **Seed**: Random seed for packet obfuscation

467

468

### HTTP/2 Options

469

- **Domain Requirements**: Requires valid domain and TLS

470

- **Path Configuration**: Custom HTTP/2 paths

471

- **Host Header**: Configurable host headers

472

473

### QUIC Options

474

- **Security**: Built-in encryption

475

- **Congestion Control**: Optimized for mobile networks

476

- **Header Obfuscation**: Packet header camouflage

477

478

## TLS and Certificate Management

479

480

### Certificate Types

481

- **Self-signed**: Generated locally for testing

482

- **Let's Encrypt**: Automatic ACME certificate generation

483

- **Custom**: User-provided certificates

484

485

### TLS Settings

486

- **Version Control**: TLS 1.2/1.3 configuration

487

- **Cipher Suites**: Configurable encryption methods

488

- **ALPN**: Application-Layer Protocol Negotiation

489

490

## Error Handling

491

492

Configuration modification functions handle:

493

- Invalid port ranges and conflicts

494

- Domain validation for TLS/CDN features

495

- Certificate generation failures

496

- Service restart failures

497

- Configuration file corruption

498

499

All functions provide detailed error messages and rollback capabilities to maintain service availability.