Skip to content

Commit

Permalink
new: add warp config
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jan 25, 2024
1 parent e45e9a3 commit 4c65b10
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hiddify/ray2sing

go 1.21.6
go 1.21.1

require (
github.com/sagernet/sing v0.3.0
Expand All @@ -21,4 +21,4 @@ require (
golang.org/x/tools v0.16.0 // indirect
)

replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.7.9-0.20240121092547-68ac7a67eee1
replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.7.9-0.20240125155948-df6318730338
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240121092547-68ac7a67eee1 h1:bzGnAZ2C8SLkra6RsJuU/eGh00I6kmFEm88Kg77QyZo=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240121092547-68ac7a67eee1/go.mod h1:UjYAsVOhYPgx2Yl53iPjIwHOp7HghictAi16Lmi+CZw=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240125155948-df6318730338 h1:8Sqfq36q1f9La853T/6VnY7IgCvfPL0uhkguyrTl3t8=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240125155948-df6318730338/go.mod h1:DnlHl/vlinL9Mn95+qJ3RzgE3E/9pWlAvTsauo7F5HM=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ var examples = map[string][]string{
"wg": {
"wg://[server]:222/?pk=[private_key]&local_address=10.0.0.2/24&peer_pk=[peer_public_key]&pre_shared_key=[pre_shared_key]&workers=[workers]&mtu=[mtu]&reserved=0,0,0",
},
"warp": {
"warp://key@host:1234/#WARPkey",
"warp://engage.cloudflareclient.com:2408#WARPnoKey",
"warp://[email protected]:2408/?ifp=5-10#WARPparam",
},
}

func main() {
Expand Down
1 change: 1 addition & 0 deletions ray2sing/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var configTypes = map[string]ParserFunc{
"ssh://": SSHSingbox,
"wg://": WiregaurdSingbox,
"ssconf://": BeepassSingbox,
"warp://": WarpSingbox,
}

func processSingleConfig(config string) (outbound *T.Outbound, err error) {
Expand Down
25 changes: 25 additions & 0 deletions ray2sing/warp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ray2sing

import (
T "github.com/sagernet/sing-box/option"
)

func WarpSingbox(url string) (*T.Outbound, error) {
u, err := ParseUrl(url)
if err != nil {
return nil, err
}
out := &T.Outbound{
Type: "custom",
Tag: u.Name,
CustomOptions: map[string]interface{}{
"warp": map[string]interface{}{
"key": u.Username,
"host": u.Hostname,
"port": u.Port,
"fakePackets": u.Params["fake_packets"],
},
},
}
return out, nil
}
5 changes: 0 additions & 5 deletions ray2sing/wireguard.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package ray2sing

import (
"fmt"
"net/netip"
"strconv"
"strings"

T "github.com/sagernet/sing-box/option"
)

func parseWireguard(inputURL string) (result map[string]string, err error) {
return nil, fmt.Errorf("Not Implemented")
}

func WiregaurdSingbox(url string) (*T.Outbound, error) {
u, err := ParseUrl(url)
if err != nil {
Expand Down

0 comments on commit 4c65b10

Please sign in to comment.