-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
498 additions
and
677 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package main | ||
package arch | ||
|
||
import ( | ||
"net" | ||
"os/exec" | ||
) | ||
|
||
func addRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
func AddRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
b, err := exec.Command("route", "-n", "add", "-net", dest.String(), gateway).Output() | ||
if err == nil { | ||
return b, nil | ||
} | ||
return exec.Command("route", "-n", "change", "-net", dest.String(), gateway).Output() | ||
} | ||
|
||
func deleteRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
func DeleteRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
return exec.Command("route", "-n", "delete", "-net", dest.String(), gateway).Output() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package main | ||
package arch | ||
|
||
import ( | ||
"net" | ||
"os/exec" | ||
) | ||
|
||
func addRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
func AddRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
out, err := exec.Command("netsh", "interface", "ipv4", "add", "route", dest.String(), "nexthop="+gateway, "interface="+devName, "metric=0", "store=active").Output() | ||
if err == nil { | ||
return out, nil | ||
} | ||
return exec.Command("netsh", "interface", "ipv4", "set", "route", dest.String(), "nexthop="+gateway, "interface="+devName, "metric=0", "store=active").Output() | ||
} | ||
|
||
func deleteRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
func DeleteRouteCmd(dest *net.IPNet, gateway, devName string) ([]byte, error) { | ||
return exec.Command("netsh", "interface", "ipv4", "delete", "route", dest.String(), "interface="+devName).Output() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package arch | ||
|
||
import ( | ||
"io" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package arch | ||
|
||
import ( | ||
"errors" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package arch | ||
|
||
import ( | ||
"io" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/jessevdk/go-flags" | ||
"github.com/nknorg/nconnect" | ||
"github.com/nknorg/nconnect/config" | ||
) | ||
|
||
func main() { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
log.Fatalf("Panic: %+v", r) | ||
} | ||
}() | ||
|
||
var opts config.Opts | ||
_, err := flags.Parse(&opts) | ||
if err != nil { | ||
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp { | ||
os.Exit(0) | ||
} | ||
log.Fatal(err) | ||
} | ||
nconnect.Run(&opts) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,91 @@ | ||
module github.com/nknorg/nconnect | ||
|
||
go 1.13 | ||
go 1.19 | ||
|
||
require ( | ||
github.com/eycorsican/go-tun2socks v1.16.11 | ||
github.com/gin-contrib/gzip v0.0.3 | ||
github.com/gin-gonic/gin v1.7.7 | ||
github.com/imdario/mergo v0.3.13 | ||
github.com/imdario/mergo v0.3.15 | ||
github.com/jessevdk/go-flags v1.5.0 | ||
github.com/nknorg/ncp-go v1.0.6-0.20230228002512-f4cd1740bebd | ||
github.com/nknorg/nkn-sdk-go v1.4.5 | ||
github.com/nknorg/nkn-tuna-session v0.2.6-0.20230328055742-9a596c57b4bb | ||
github.com/nknorg/nkn-tunnel v0.3.5-0.20230328060135-8eb315c90047 | ||
github.com/nknorg/nkn-sdk-go v1.4.6-0.20230404044330-ad192f36d07e | ||
github.com/nknorg/nkn-tuna-session v0.2.6-0.20230415032955-7a3fc7be9634 | ||
github.com/nknorg/nkn-tunnel v0.3.5-0.20230418225220-c505086e1505 | ||
github.com/nknorg/nkn/v2 v2.2.0 | ||
github.com/nknorg/nkngomobile v0.0.0-20220615081414-671ad1afdfa9 | ||
github.com/nknorg/tuna v0.0.0-20230328054959-0bc6eb5bf369 | ||
github.com/shadowsocks/go-shadowsocks2 v0.1.2 | ||
github.com/txthinking/brook v0.0.0-20230418095906-76ced63f1803 | ||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 | ||
) | ||
|
||
require ( | ||
github.com/BurntSushi/toml v1.2.1 // indirect | ||
github.com/andybalholm/brotli v1.0.4 // indirect | ||
github.com/gaukas/godicttls v0.0.3 // indirect | ||
github.com/gin-contrib/sse v0.1.0 // indirect | ||
github.com/go-playground/locales v0.13.0 // indirect | ||
github.com/go-playground/universal-translator v0.17.0 // indirect | ||
github.com/go-playground/validator/v10 v10.4.1 // indirect | ||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect | ||
github.com/golang/mock v1.6.0 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect | ||
github.com/gorilla/mux v1.8.0 // indirect | ||
github.com/gorilla/websocket v1.5.0 // indirect | ||
github.com/hashicorp/errwrap v1.1.0 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/itchyny/base58-go v0.2.1 // indirect | ||
github.com/jpillora/backoff v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.9 // indirect | ||
github.com/klauspost/compress v1.15.15 // indirect | ||
github.com/krolaw/dhcp4 v0.0.0-20190909130307-a50d88189771 // indirect | ||
github.com/leodido/go-urn v1.2.0 // indirect | ||
github.com/mattn/go-isatty v0.0.12 // indirect | ||
github.com/miekg/dns v1.1.51 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.1 // indirect | ||
github.com/nknorg/encrypted-stream v1.0.2-0.20230320101720-9891f770de86 // indirect | ||
github.com/onsi/ginkgo/v2 v2.2.0 // indirect | ||
github.com/oschwald/geoip2-golang v1.4.0 // indirect | ||
github.com/oschwald/maxminddb-golang v1.6.0 // indirect | ||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect | ||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect | ||
github.com/phuslu/iploc v1.0.20230201 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect | ||
github.com/quic-go/qtls-go1-19 v0.2.0 // indirect | ||
github.com/quic-go/qtls-go1-20 v0.1.0 // indirect | ||
github.com/quic-go/quic-go v0.32.0 // indirect | ||
github.com/rdegges/go-ipify v0.0.0-20150526035502-2d94a6a86c40 // indirect | ||
github.com/refraction-networking/utls v1.3.2 // indirect | ||
github.com/riobard/go-bloom v0.0.0-20200213042214-218e1707c495 // indirect | ||
github.com/rogpeppe/go-internal v1.10.0 // indirect | ||
github.com/songgao/water v0.0.0-20190725173103-fd331bda3f4b // indirect | ||
github.com/tdewolff/minify v2.3.6+incompatible // indirect | ||
github.com/tdewolff/parse v2.3.4+incompatible // indirect | ||
github.com/txthinking/crypto v0.0.0-20210716135230-de9624a415a4 // indirect | ||
github.com/txthinking/runnergroup v0.0.0-20230211072751-d11f16258c86 // indirect | ||
github.com/txthinking/socks5 v0.0.0-20230307062227-0e1677eca4ba // indirect | ||
github.com/txthinking/x v0.0.0-20220929041811-1b4d914e9133 // indirect | ||
github.com/ugorji/go/codec v1.1.7 // indirect | ||
github.com/urfave/negroni v1.0.0 // indirect | ||
github.com/xtaci/smux v2.0.1+incompatible // indirect | ||
golang.org/x/crypto v0.7.0 // indirect | ||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect | ||
golang.org/x/mobile v0.0.0-20230301163155-e0f57694e12c // indirect | ||
golang.org/x/mod v0.8.0 // indirect | ||
golang.org/x/net v0.8.0 // indirect | ||
golang.org/x/sys v0.6.0 // indirect | ||
golang.org/x/text v0.8.0 // indirect | ||
golang.org/x/tools v0.6.0 // indirect | ||
google.golang.org/protobuf v1.29.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
) | ||
|
||
//replace github.com/nknorg/tuna v0.0.0-20230128070346-2e1102d13fcb => github.com/nknorg/tuna v0.0.0-20230128070346-2e1102d13fcb | ||
// | ||
//replace github.com/nknorg/nkn-tuna-session v0.2.5 => github.com/nknorg/nkn-tuna-session v0.2.6-0.20230129080815-6bcf65132ef1 | ||
// | ||
//replace github.com/nknorg/nkn-tunnel v0.3.4 => github.com/nknorg/nkn-tunnel v0.3.5-0.20230129081143-f866961b9676 |
Oops, something went wrong.