Skip to content

Commit 05345cc

Browse files
authored
Add Mekya Stereotype (v2fly#3185)
* Add mekya stereotype config * Add mekya stereotype config: autogenerated * add autogenerated files * add mekya stereotype * add mekya stereotype: fixup * add mekya stereotype to default distro * add mekya testing
1 parent 5ffbc02 commit 05345cc

File tree

8 files changed

+586
-0
lines changed

8 files changed

+586
-0
lines changed

main/distro/all/all.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import (
7777
_ "github.com/v2fly/v2ray-core/v5/transport/internet/request/assembler/packetconn"
7878

7979
_ "github.com/v2fly/v2ray-core/v5/transport/internet/request/stereotype/meek"
80+
_ "github.com/v2fly/v2ray-core/v5/transport/internet/request/stereotype/mekya"
8081

8182
_ "github.com/v2fly/v2ray-core/v5/transport/internet/dtls"
8283

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"log": {
3+
"error": {
4+
"level": "Debug",
5+
"type": "Console"
6+
},
7+
"access": {
8+
"type": "None"
9+
}
10+
},
11+
"outbounds": [
12+
{
13+
"protocol": "vmess",
14+
"settings": {
15+
"address": "127.0.0.1",
16+
"port": 17773,
17+
"uuid": "bcc71618-e552-42c2-a2a3-d4c17a9df764"
18+
},
19+
"streamSettings": {
20+
"transport": "mekya",
21+
"transportSettings": {
22+
"url": "https://127.0.0.1:17773/mrss48bvxrkfq1qzeqte5o61mmvc9gx6hq51",
23+
"maxWriteDelay": 80,
24+
"maxRequestSize": 96000,
25+
"pollingIntervalInitial": 200,
26+
"h2_pool_size": 8,
27+
"kcp": {
28+
"mtu": {
29+
"value": 1450
30+
},
31+
"tti": {
32+
"value": 15
33+
},
34+
"uplink_capacity": {
35+
"value": 40
36+
},
37+
"downlink_capacity": {
38+
"value": 2000
39+
},
40+
"congestion": false,
41+
"write_buffer": {
42+
"size": 671088640
43+
},
44+
"read_buffer": {
45+
"size": 671088640
46+
}
47+
}
48+
},
49+
"security": "tls",
50+
"securitySettings": {
51+
"pinnedPeerCertificateChainSha256": [
52+
"kqHyvea27Pn+JiSqA72lhu9IKAKeGR+3yCyA8JR1mug="
53+
],
54+
"allowInsecureIfPinnedPeerCertificate": true
55+
}
56+
}
57+
}
58+
],
59+
"inbounds": [
60+
{
61+
"protocol": "socks",
62+
"settings": {
63+
"udpEnabled": false,
64+
"address": "127.0.0.1",
65+
"packetEncoding": "Packet"
66+
},
67+
"port": 17774,
68+
"listen": "127.0.0.1"
69+
}
70+
]
71+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"log": {
3+
"error": {
4+
"level": "Debug",
5+
"type": "Console"
6+
},
7+
"access": {
8+
"type": "None"
9+
}
10+
},
11+
"outbounds": [
12+
{
13+
"protocol": "freedom"
14+
}
15+
],
16+
"inbounds": [
17+
{
18+
"listen": "127.0.0.1",
19+
"port": 17773,
20+
"protocol": "vmess",
21+
"settings": {
22+
"users": [
23+
"bcc71618-e552-42c2-a2a3-d4c17a9df764"
24+
]
25+
},
26+
"streamSettings": {
27+
"transport": "mekya",
28+
"transportSettings": {
29+
"url": "http://127.0.0.1:12777",
30+
"maxWriteSize": 10485760,
31+
"maxWriteDurationMs": 5000,
32+
"maxSimultaneousWriteConnection": 128,
33+
"packetWritingBuffer": 65536,
34+
"kcp": {
35+
"mtu": {
36+
"value": 1450
37+
},
38+
"tti": {
39+
"value": 15
40+
},
41+
"uplink_capacity": {
42+
"value": 40
43+
},
44+
"downlink_capacity": {
45+
"value": 2000
46+
},
47+
"congestion": false,
48+
"write_buffer": {
49+
"size": 671088640
50+
},
51+
"read_buffer": {
52+
"size": 671088640
53+
}
54+
}
55+
},
56+
"security": "tls",
57+
"securitySettings": {
58+
"certificate": [
59+
{
60+
"usage": "ENCIPHERMENT",
61+
"certificateFile": "cert/self-signed_cert.pem",
62+
"keyFile": "cert/self-signed_key.pem"
63+
}
64+
]
65+
}
66+
}
67+
}
68+
]
69+
}

testing/scenarios/mekya_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package scenarios
2+
3+
import (
4+
"context"
5+
"os"
6+
"testing"
7+
"time"
8+
9+
"github.com/v2fly/v2ray-core/v5/common"
10+
"github.com/v2fly/v2ray-core/v5/testing/servers/tcp"
11+
12+
_ "github.com/v2fly/v2ray-core/v5/main/distro/all"
13+
)
14+
15+
func TestMekya(t *testing.T) {
16+
tcpServer := tcp.Server{
17+
MsgProcessor: xor,
18+
}
19+
dest, err := tcpServer.Start()
20+
common.Must(err)
21+
defer tcpServer.Close()
22+
23+
coreInst, InstMgrIfce := NewInstanceManagerCoreInstance()
24+
defer coreInst.Close()
25+
26+
common.Must(InstMgrIfce.AddInstance(
27+
context.TODO(),
28+
"mekya_client",
29+
common.Must2(os.ReadFile("config/mekya_client.json")).([]byte),
30+
"jsonv5"))
31+
32+
common.Must(InstMgrIfce.AddInstance(
33+
context.TODO(),
34+
"mekya_server",
35+
common.Must2(os.ReadFile("config/mekya_server.json")).([]byte),
36+
"jsonv5"))
37+
38+
common.Must(InstMgrIfce.StartInstance(context.TODO(), "mekya_server"))
39+
common.Must(InstMgrIfce.StartInstance(context.TODO(), "mekya_client"))
40+
41+
defer func() {
42+
common.Must(InstMgrIfce.StopInstance(context.TODO(), "mekya_server"))
43+
common.Must(InstMgrIfce.StopInstance(context.TODO(), "mekya_client"))
44+
common.Must(InstMgrIfce.UntrackInstance(context.TODO(), "mekya_server"))
45+
common.Must(InstMgrIfce.UntrackInstance(context.TODO(), "mekya_client"))
46+
coreInst.Close()
47+
}()
48+
49+
if err := testTCPConnViaSocks(17774, dest.Port, 1024, time.Second*2)(); err != nil {
50+
t.Error(err)
51+
}
52+
}

0 commit comments

Comments
 (0)