Merge branch 'ogn-dev' into with-tun
This commit is contained in:
commit
5e0d4930cb
13 changed files with 23 additions and 104 deletions
|
@ -19,7 +19,12 @@ func HandleConn(c net.Conn, in chan<- C.ConnContext, cache *cache.Cache) {
|
||||||
client := newClient(c.RemoteAddr(), in)
|
client := newClient(c.RemoteAddr(), in)
|
||||||
defer client.CloseIdleConnections()
|
defer client.CloseIdleConnections()
|
||||||
|
|
||||||
conn := N.NewBufferedConn(c)
|
var conn *N.BufferedConn
|
||||||
|
if bufConn, ok := c.(*N.BufferedConn); ok {
|
||||||
|
conn = bufConn
|
||||||
|
} else {
|
||||||
|
conn = N.NewBufferedConn(c)
|
||||||
|
}
|
||||||
|
|
||||||
keepAlive := true
|
keepAlive := true
|
||||||
trusted := cache == nil // disable authenticate if cache is nil
|
trusted := cache == nil // disable authenticate if cache is nil
|
||||||
|
|
|
@ -64,6 +64,8 @@ func New(addr string, in chan<- C.ConnContext) (*Listener, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleConn(conn net.Conn, in chan<- C.ConnContext, cache *cache.Cache) {
|
func handleConn(conn net.Conn, in chan<- C.ConnContext, cache *cache.Cache) {
|
||||||
|
conn.(*net.TCPConn).SetKeepAlive(true)
|
||||||
|
|
||||||
bufConn := N.NewBufferedConn(conn)
|
bufConn := N.NewBufferedConn(conn)
|
||||||
head, err := bufConn.Peek(1)
|
head, err := bufConn.Peek(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -61,6 +61,7 @@ func New(addr string, in chan<- C.ConnContext) (*Listener, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSocks(conn net.Conn, in chan<- C.ConnContext) {
|
func handleSocks(conn net.Conn, in chan<- C.ConnContext) {
|
||||||
|
conn.(*net.TCPConn).SetKeepAlive(true)
|
||||||
bufConn := N.NewBufferedConn(conn)
|
bufConn := N.NewBufferedConn(conn)
|
||||||
head, err := bufConn.Peek(1)
|
head, err := bufConn.Peek(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -84,9 +85,6 @@ func HandleSocks4(conn net.Conn, in chan<- C.ConnContext) {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c, ok := conn.(*net.TCPConn); ok {
|
|
||||||
c.SetKeepAlive(true)
|
|
||||||
}
|
|
||||||
in <- inbound.NewSocket(socks5.ParseAddr(addr), conn, C.SOCKS4)
|
in <- inbound.NewSocket(socks5.ParseAddr(addr), conn, C.SOCKS4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,9 +94,6 @@ func HandleSocks5(conn net.Conn, in chan<- C.ConnContext) {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c, ok := conn.(*net.TCPConn); ok {
|
|
||||||
c.SetKeepAlive(true)
|
|
||||||
}
|
|
||||||
if command == socks5.CmdUDPAssociate {
|
if command == socks5.CmdUDPAssociate {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
io.Copy(io.Discard, conn)
|
io.Copy(io.Discard, conn)
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
"inbounds": [
|
|
||||||
{
|
|
||||||
"port": 10002,
|
|
||||||
"listen": "0.0.0.0",
|
|
||||||
"protocol": "vmess",
|
|
||||||
"settings": {
|
|
||||||
"clients": [
|
|
||||||
{
|
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
||||||
"alterId": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"streamSettings": {
|
|
||||||
"network": "tcp"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outbounds": [
|
|
||||||
{
|
|
||||||
"protocol": "freedom"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"log": {
|
|
||||||
"loglevel": "debug"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
|
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
|
||||||
"alterId": 32
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -34,51 +34,12 @@ func TestClash_Vmess(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
||||||
Name: "vmess",
|
Name: "vmess",
|
||||||
Server: localIP.String(),
|
Server: localIP.String(),
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
UDP: true,
|
||||||
UDP: true,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
assert.FailNow(t, err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(waitTime)
|
|
||||||
testSuit(t, proxy)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestClash_VmessAEAD(t *testing.T) {
|
|
||||||
configPath := C.Path.Resolve("vmess-aead.json")
|
|
||||||
|
|
||||||
cfg := &container.Config{
|
|
||||||
Image: ImageVmess,
|
|
||||||
ExposedPorts: defaultExposedPorts,
|
|
||||||
}
|
|
||||||
hostCfg := &container.HostConfig{
|
|
||||||
PortBindings: defaultPortBindings,
|
|
||||||
Binds: []string{fmt.Sprintf("%s:/etc/v2ray/config.json", configPath)},
|
|
||||||
}
|
|
||||||
|
|
||||||
id, err := startContainer(cfg, hostCfg, "vmess-aead")
|
|
||||||
if err != nil {
|
|
||||||
assert.FailNow(t, err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Cleanup(func() {
|
|
||||||
cleanContainer(id)
|
|
||||||
})
|
|
||||||
|
|
||||||
proxy, err := outbound.NewVmess(outbound.VmessOption{
|
|
||||||
Name: "vmess",
|
|
||||||
Server: localIP.String(),
|
|
||||||
Port: 10002,
|
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
|
||||||
Cipher: "auto",
|
|
||||||
AlterID: 0,
|
|
||||||
UDP: true,
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
assert.FailNow(t, err.Error())
|
assert.FailNow(t, err.Error())
|
||||||
|
@ -114,7 +75,6 @@ func TestClash_VmessTLS(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
TLS: true,
|
TLS: true,
|
||||||
SkipCertVerify: true,
|
SkipCertVerify: true,
|
||||||
ServerName: "example.org",
|
ServerName: "example.org",
|
||||||
|
@ -154,7 +114,6 @@ func TestClash_VmessHTTP2(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
Network: "h2",
|
Network: "h2",
|
||||||
TLS: true,
|
TLS: true,
|
||||||
SkipCertVerify: true,
|
SkipCertVerify: true,
|
||||||
|
@ -197,7 +156,6 @@ func TestClash_VmessHTTP(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
Network: "http",
|
Network: "http",
|
||||||
UDP: true,
|
UDP: true,
|
||||||
HTTPOpts: outbound.HTTPOptions{
|
HTTPOpts: outbound.HTTPOptions{
|
||||||
|
@ -250,7 +208,6 @@ func TestClash_VmessWebsocket(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
Network: "ws",
|
Network: "ws",
|
||||||
UDP: true,
|
UDP: true,
|
||||||
})
|
})
|
||||||
|
@ -288,7 +245,6 @@ func TestClash_VmessWebsocketTLS(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
Network: "ws",
|
Network: "ws",
|
||||||
TLS: true,
|
TLS: true,
|
||||||
SkipCertVerify: true,
|
SkipCertVerify: true,
|
||||||
|
@ -328,7 +284,6 @@ func TestClash_VmessGrpc(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
Network: "grpc",
|
Network: "grpc",
|
||||||
TLS: true,
|
TLS: true,
|
||||||
SkipCertVerify: true,
|
SkipCertVerify: true,
|
||||||
|
@ -370,7 +325,6 @@ func TestClash_VmessWebsocket0RTT(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
Network: "ws",
|
Network: "ws",
|
||||||
UDP: true,
|
UDP: true,
|
||||||
ServerName: "example.org",
|
ServerName: "example.org",
|
||||||
|
@ -411,7 +365,6 @@ func TestClash_VmessWebsocketXray0RTT(t *testing.T) {
|
||||||
Port: 10002,
|
Port: 10002,
|
||||||
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
UUID: "b831381d-6324-4d53-ad4f-8cda48b30811",
|
||||||
Cipher: "auto",
|
Cipher: "auto",
|
||||||
AlterID: 32,
|
|
||||||
Network: "ws",
|
Network: "ws",
|
||||||
UDP: true,
|
UDP: true,
|
||||||
ServerName: "example.org",
|
ServerName: "example.org",
|
||||||
|
|
Loading…
Reference in a new issue