mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
feat: Add port for socks5 proxy with rule (#404)
Co-authored-by: mzz2017 <mzz@tuta.io>
This commit is contained in:
1 parent
e7839b5e9d
commit
ddb2bca53b
8 files changed
+67
-15
No files matched your search
@@ -44,6 +44,18 @@
|
||||
required
|
||||
></b-input>
|
||||
</b-field>
|
||||
<b-field
|
||||
:label="$t('customAddressPort.portSocks5WithPac')"
|
||||
label-position="on-border"
|
||||
>
|
||||
<b-input
|
||||
v-model="table.socks5WithPac"
|
||||
placeholder="0"
|
||||
type="number"
|
||||
min="0"
|
||||
required
|
||||
></b-input>
|
||||
</b-field>
|
||||
<b-field
|
||||
:label="$t('customAddressPort.portHttpWithPac')"
|
||||
label-position="on-border"
|
||||
@@ -123,6 +135,7 @@ export default {
|
||||
backendAddress: "http://localhost:2017",
|
||||
socks5: "20170",
|
||||
http: "20171",
|
||||
socks5WithPac: "0",
|
||||
httpWithPac: "20172",
|
||||
vlessGrpc: "0",
|
||||
vlessGrpcLink: ""
|
||||
@@ -170,6 +183,7 @@ export default {
|
||||
data: {
|
||||
socks5: parseInt(this.table.socks5),
|
||||
http: parseInt(this.table.http),
|
||||
socks5WithPac: parseInt(this.table.socks5WithPac),
|
||||
httpWithPac: parseInt(this.table.httpWithPac),
|
||||
vlessGrpc: parseInt(this.table.vlessGrpc)
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ export default {
|
||||
serviceAddress: "Address of Service",
|
||||
portSocks5: "Port of SOCKS5",
|
||||
portHttp: "Port of HTTP",
|
||||
portSocks5WithPac: "Port of SOCKS5(with Rule)",
|
||||
portHttpWithPac: "Port of HTTP(with Rule)",
|
||||
portVlessGrpc: "Port of VLESS-GRPC(with Rule)",
|
||||
portVlessGrpcPrompt: "Link of VLESS-GRPC port",
|
||||
|
||||
@@ -156,6 +156,7 @@ export default {
|
||||
serviceAddress: "服务端地址",
|
||||
portSocks5: "socks5端口",
|
||||
portHttp: "http端口",
|
||||
portSocks5WithPac: "socks5端口(带分流规则)",
|
||||
portHttpWithPac: "http端口(带分流规则)",
|
||||
portVlessGrpc: "VLESS-GRPC端口(带分流规则)",
|
||||
portVlessGrpcLink: "VLESS-GRPC端口链接",
|
||||
|
||||
@@ -36,6 +36,26 @@ const TemplateJson = `
|
||||
},
|
||||
"tag": "http"
|
||||
},
|
||||
{
|
||||
"port": 0,
|
||||
"listen": "0.0.0.0",
|
||||
"protocol": "socks",
|
||||
"sniffing": {
|
||||
"enabled": true,
|
||||
"destOverride": [
|
||||
"http",
|
||||
"tls"
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": true,
|
||||
"ip": null,
|
||||
"clients": null
|
||||
},
|
||||
"streamSettings": null,
|
||||
"tag": "rule-socks"
|
||||
},
|
||||
{
|
||||
"port": 20172,
|
||||
"listen": "0.0.0.0",
|
||||
@@ -47,7 +67,7 @@ const TemplateJson = `
|
||||
"tls"
|
||||
]
|
||||
},
|
||||
"tag": "rule"
|
||||
"tag": "rule-http"
|
||||
},
|
||||
{
|
||||
"listen": "0.0.0.0",
|
||||
|
||||
@@ -589,7 +589,9 @@ func (t *Template) AppendRoutingRuleByMode(mode configure.RulePortMode, inbounds
|
||||
}
|
||||
|
||||
func (t *Template) setRulePortRouting() error {
|
||||
return t.AppendRoutingRuleByMode(t.Setting.RulePortMode, []string{"rule"})
|
||||
// append rule-http and rule-socks no mather if they are enabled
|
||||
// because "The Same as the Rule Port" may need them
|
||||
return t.AppendRoutingRuleByMode(t.Setting.RulePortMode, []string{"rule-http", "rule-socks"})
|
||||
}
|
||||
func parseRoutingA(t *Template, routingInboundTags []string) error {
|
||||
lines := strings.Split(configure.GetRoutingA(), "\n")
|
||||
@@ -797,7 +799,7 @@ func parseRoutingA(t *Template, routingInboundTags []string) error {
|
||||
t.Routing.Rules = append(t.Routing.Rules, coreObj.RoutingRule{
|
||||
Type: "field",
|
||||
OutboundTag: defaultOutbound,
|
||||
InboundTag: []string{"rule"},
|
||||
InboundTag: []string{"rule-http", "rule-socks"},
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -814,7 +816,7 @@ func (t *Template) setTransparentRouting() (err error) {
|
||||
for i := range t.Routing.Rules {
|
||||
ok := false
|
||||
for _, in := range t.Routing.Rules[i].InboundTag {
|
||||
if in == "rule" {
|
||||
if in == "rule-http" {
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
@@ -1011,8 +1013,9 @@ func (t *Template) setInbound() error {
|
||||
if p != nil {
|
||||
t.Inbounds[0].Port = p.Socks5
|
||||
t.Inbounds[1].Port = p.Http
|
||||
t.Inbounds[2].Port = p.HttpWithPac
|
||||
vlessGrpc := &t.Inbounds[3]
|
||||
t.Inbounds[2].Port = p.Socks5WithPac
|
||||
t.Inbounds[3].Port = p.HttpWithPac
|
||||
vlessGrpc := &t.Inbounds[4]
|
||||
vlessGrpc.Port = p.VlessGrpc
|
||||
if p.VlessGrpc > 0 {
|
||||
if err := service.CheckGrpcSupported(); err != nil {
|
||||
@@ -1448,7 +1451,7 @@ func (t *Template) setVlessGrpcRouting() {
|
||||
for i := range t.Routing.Rules {
|
||||
var bHasRule bool
|
||||
for _, tag := range t.Routing.Rules[i].InboundTag {
|
||||
if tag == "rule" {
|
||||
if tag == "rule-http" {
|
||||
bHasRule = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,11 @@ func New() *Configure {
|
||||
Setting: NewSetting(),
|
||||
Accounts: map[string]string{},
|
||||
Ports: Ports{
|
||||
Socks5: 20170,
|
||||
Http: 20171,
|
||||
HttpWithPac: 20172,
|
||||
VlessGrpc: 0,
|
||||
Socks5: 20170,
|
||||
Socks5WithPac: 0,
|
||||
Http: 20171,
|
||||
HttpWithPac: 20172,
|
||||
VlessGrpc: 0,
|
||||
},
|
||||
InternalDnsList: nil,
|
||||
ExternalDnsList: nil,
|
||||
@@ -260,6 +261,7 @@ func GetPortsNotNil() *Ports {
|
||||
p = new(Ports)
|
||||
p.Socks5 = 20170
|
||||
p.Http = 20171
|
||||
p.Socks5WithPac = 0
|
||||
p.HttpWithPac = 20172
|
||||
p.VlessGrpc = 0
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package configure
|
||||
|
||||
type Ports struct {
|
||||
Socks5 int `json:"socks5"`
|
||||
Http int `json:"http"`
|
||||
HttpWithPac int `json:"httpWithPac"`
|
||||
VlessGrpc int `json:"vlessGrpc"`
|
||||
Socks5 int `json:"socks5"`
|
||||
Http int `json:"http"`
|
||||
Socks5WithPac int `json:"socks5WithPac"`
|
||||
HttpWithPac int `json:"httpWithPac"`
|
||||
VlessGrpc int `json:"vlessGrpc"`
|
||||
}
|
||||
@@ -24,6 +24,10 @@ func SetPorts(ports *configure.Ports) (err error) {
|
||||
set[ports.Http] = struct{}{}
|
||||
cnt++
|
||||
}
|
||||
if ports.Socks5WithPac != 0 {
|
||||
set[ports.Socks5WithPac] = struct{}{}
|
||||
cnt++
|
||||
}
|
||||
if ports.HttpWithPac != 0 {
|
||||
set[ports.HttpWithPac] = struct{}{}
|
||||
cnt++
|
||||
@@ -48,6 +52,12 @@ func SetPorts(ports *configure.Ports) (err error) {
|
||||
detectSyntax = append(detectSyntax, strconv.Itoa(origin.Http)+":tcp")
|
||||
}
|
||||
}
|
||||
if ports.Socks5WithPac != origin.Socks5WithPac {
|
||||
origin.Socks5WithPac = ports.Socks5WithPac
|
||||
if origin.Socks5WithPac != 0 {
|
||||
detectSyntax = append(detectSyntax, strconv.Itoa(origin.Socks5WithPac)+":tcp,udp")
|
||||
}
|
||||
}
|
||||
if ports.HttpWithPac != origin.HttpWithPac {
|
||||
origin.HttpWithPac = ports.HttpWithPac
|
||||
if origin.HttpWithPac != 0 {
|
||||
|
||||
Reference in new issue
Block a user