Skip to content

Commit

Permalink
Add Mekya Stereotype (#3185)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xiaokangwang authored Oct 12, 2024
1 parent 5ffbc02 commit 05345cc
Show file tree
Hide file tree
Showing 8 changed files with 586 additions and 0 deletions.
1 change: 1 addition & 0 deletions main/distro/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import (
_ "github.com/v2fly/v2ray-core/v5/transport/internet/request/assembler/packetconn"

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

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

Expand Down
71 changes: 71 additions & 0 deletions testing/scenarios/config/mekya_client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"log": {
"error": {
"level": "Debug",
"type": "Console"
},
"access": {
"type": "None"
}
},
"outbounds": [
{
"protocol": "vmess",
"settings": {
"address": "127.0.0.1",
"port": 17773,
"uuid": "bcc71618-e552-42c2-a2a3-d4c17a9df764"
},
"streamSettings": {
"transport": "mekya",
"transportSettings": {
"url": "https://127.0.0.1:17773/mrss48bvxrkfq1qzeqte5o61mmvc9gx6hq51",
"maxWriteDelay": 80,
"maxRequestSize": 96000,
"pollingIntervalInitial": 200,
"h2_pool_size": 8,
"kcp": {
"mtu": {
"value": 1450
},
"tti": {
"value": 15
},
"uplink_capacity": {
"value": 40
},
"downlink_capacity": {
"value": 2000
},
"congestion": false,
"write_buffer": {
"size": 671088640
},
"read_buffer": {
"size": 671088640
}
}
},
"security": "tls",
"securitySettings": {
"pinnedPeerCertificateChainSha256": [
"kqHyvea27Pn+JiSqA72lhu9IKAKeGR+3yCyA8JR1mug="
],
"allowInsecureIfPinnedPeerCertificate": true
}
}
}
],
"inbounds": [
{
"protocol": "socks",
"settings": {
"udpEnabled": false,
"address": "127.0.0.1",
"packetEncoding": "Packet"
},
"port": 17774,
"listen": "127.0.0.1"
}
]
}
69 changes: 69 additions & 0 deletions testing/scenarios/config/mekya_server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"log": {
"error": {
"level": "Debug",
"type": "Console"
},
"access": {
"type": "None"
}
},
"outbounds": [
{
"protocol": "freedom"
}
],
"inbounds": [
{
"listen": "127.0.0.1",
"port": 17773,
"protocol": "vmess",
"settings": {
"users": [
"bcc71618-e552-42c2-a2a3-d4c17a9df764"
]
},
"streamSettings": {
"transport": "mekya",
"transportSettings": {
"url": "http://127.0.0.1:12777",
"maxWriteSize": 10485760,
"maxWriteDurationMs": 5000,
"maxSimultaneousWriteConnection": 128,
"packetWritingBuffer": 65536,
"kcp": {
"mtu": {
"value": 1450
},
"tti": {
"value": 15
},
"uplink_capacity": {
"value": 40
},
"downlink_capacity": {
"value": 2000
},
"congestion": false,
"write_buffer": {
"size": 671088640
},
"read_buffer": {
"size": 671088640
}
}
},
"security": "tls",
"securitySettings": {
"certificate": [
{
"usage": "ENCIPHERMENT",
"certificateFile": "cert/self-signed_cert.pem",
"keyFile": "cert/self-signed_key.pem"
}
]
}
}
}
]
}
52 changes: 52 additions & 0 deletions testing/scenarios/mekya_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package scenarios

import (
"context"
"os"
"testing"
"time"

"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/testing/servers/tcp"

_ "github.com/v2fly/v2ray-core/v5/main/distro/all"
)

func TestMekya(t *testing.T) {
tcpServer := tcp.Server{
MsgProcessor: xor,
}
dest, err := tcpServer.Start()
common.Must(err)
defer tcpServer.Close()

coreInst, InstMgrIfce := NewInstanceManagerCoreInstance()
defer coreInst.Close()

common.Must(InstMgrIfce.AddInstance(
context.TODO(),
"mekya_client",
common.Must2(os.ReadFile("config/mekya_client.json")).([]byte),
"jsonv5"))

common.Must(InstMgrIfce.AddInstance(
context.TODO(),
"mekya_server",
common.Must2(os.ReadFile("config/mekya_server.json")).([]byte),
"jsonv5"))

common.Must(InstMgrIfce.StartInstance(context.TODO(), "mekya_server"))
common.Must(InstMgrIfce.StartInstance(context.TODO(), "mekya_client"))

defer func() {
common.Must(InstMgrIfce.StopInstance(context.TODO(), "mekya_server"))
common.Must(InstMgrIfce.StopInstance(context.TODO(), "mekya_client"))
common.Must(InstMgrIfce.UntrackInstance(context.TODO(), "mekya_server"))
common.Must(InstMgrIfce.UntrackInstance(context.TODO(), "mekya_client"))
coreInst.Close()
}()

if err := testTCPConnViaSocks(17774, dest.Port, 1024, time.Second*2)(); err != nil {
t.Error(err)
}
}
Loading

0 comments on commit 05345cc

Please sign in to comment.