feat: Implement windows system dns setter &

feat: Modify auto completer &
feat: User auto completer for hijack rules
This commit is contained in:
Nova 2024-09-21 14:27:38 +03:30
parent 41648c0db7
commit 04ac05e815
No known key found for this signature in database
GPG Key ID: 389787EC83F5D73A
21 changed files with 1354 additions and 153 deletions

View File

@ -79,7 +79,7 @@ namespace Qv2ray::ui::widgets {
void AutoCompleteTextEdit::insertCompletion(const QString &completion) {
QTextCursor tc = textCursor();
tc.select(QTextCursor::WordUnderCursor);
tc.select(QTextCursor::LineUnderCursor);
tc.removeSelectedText();
tc.insertText(completion);
setTextCursor(tc);
@ -145,7 +145,7 @@ namespace Qv2ray::ui::widgets {
return;
}
if (auto word = wordUnderCursor(); word != c->completionPrefix()) {
if (auto word = lineUnderCursor(); word != c->completionPrefix()) {
c->setCompletionPrefix(word);
c->popup()->setCurrentIndex(c->completionModel()->index(0, 0));
}

View File

@ -1,9 +1,9 @@
module nekobox_core
go 1.19
go 1.21
require (
github.com/Mahdi-zarei/sing-box-extra v0.0.0-20240918062427-6045c5730e82
github.com/Mahdi-zarei/sing-box-extra v0.0.0-20240921073617-57308c84a31e
github.com/matsuridayo/libneko v0.0.0-20230913024055-5277a5bfc889
github.com/sagernet/sing v0.5.0-beta.2
github.com/sagernet/sing-box v1.10.0-beta.6
@ -16,7 +16,7 @@ replace github.com/sagernet/sing-dns => github.com/Mahdi-zarei/sing-dns v0.3.0-b
require (
berty.tech/go-libtor v1.0.385 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/caddyserver/certmagic v0.20.0 // indirect
@ -86,19 +86,19 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.23.0 // indirect
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
lukechampine.com/blake3 v1.3.0 // indirect
)

View File

@ -1,13 +1,13 @@
berty.tech/go-libtor v1.0.385 h1:RWK94C3hZj6Z2GdvePpHJLnWYobFr3bY/OdUJ5aoEXw=
berty.tech/go-libtor v1.0.385/go.mod h1:9swOOQVb+kmvuAlsgWUK/4c52pm69AdbJsxLzk+fJEw=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc=
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=
cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mahdi-zarei/sing-box v1.3.5-0.20240920073315-bc73938972f4 h1:8joOa6IehQSy5wKnTN2YBuvwKZf0sfSvdU1dC2hCeJ8=
github.com/Mahdi-zarei/sing-box v1.3.5-0.20240920073315-bc73938972f4/go.mod h1:MSnb8j3iBcjvuf/w7SfApa1WgBC6XecxhBeLt1vzDJk=
github.com/Mahdi-zarei/sing-box-extra v0.0.0-20240918062427-6045c5730e82 h1:h09DnPUhOGfhg7I3aJJehkjo/oC2QH4APxnWjxk/wZo=
github.com/Mahdi-zarei/sing-box-extra v0.0.0-20240918062427-6045c5730e82/go.mod h1:5/Y7uNbJpofpogdnG5Ao/Yz+bjnA8cOU1nInfA+tV4s=
github.com/Mahdi-zarei/sing-box-extra v0.0.0-20240921073617-57308c84a31e h1:LPp4Da8Q70c4x6wfy6ySVEHVcxvsLqigWp6sUUTql9A=
github.com/Mahdi-zarei/sing-box-extra v0.0.0-20240921073617-57308c84a31e/go.mod h1:5/Y7uNbJpofpogdnG5Ao/Yz+bjnA8cOU1nInfA+tV4s=
github.com/Mahdi-zarei/sing-dns v0.3.0-beta.14.0.20240918175353-709eafff43d3 h1:1YoZLwSYHOZ9J9DftJrI/FADEjv29kPptn5g34A3vC4=
github.com/Mahdi-zarei/sing-dns v0.3.0-beta.14.0.20240918175353-709eafff43d3/go.mod h1:rscgSr5ixOPk8XM9ZMLuMXCyldEQ1nLvdl0nfv+lp00=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
@ -46,6 +46,7 @@ github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIo
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
@ -63,7 +64,8 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@ -117,6 +119,7 @@ github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eyk
github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss=
github.com/onsi/ginkgo/v2 v2.9.7/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0=
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4=
github.com/ooni/go-libtor v1.1.8 h1:Wo3V3DVTxl5vZdxtQakqYP+DAHx7pPtAFSl1bnAa08w=
github.com/ooni/go-libtor v1.1.8/go.mod h1:q1YyLwRD9GeMyeerVvwc0vJ2YgwDLTp2bdVcrh/JXyI=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
@ -189,6 +192,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 h1:tHNk7XK9GkmKUR6Gh8gVBKXc2MVSZ4G/NnWLtzw4gNA=
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923/go.mod h1:eLL9Nub3yfAho7qB0MzZizFhTU2QkLeoVsWdHtDW264=
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
@ -204,6 +208,7 @@ github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
@ -217,8 +222,8 @@ golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaE
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
@ -240,10 +245,11 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -268,7 +274,8 @@ golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@ -295,21 +302,20 @@ golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvY
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c h1:lfpJ/2rWPa/kJgxyyXM8PrNnfCzcmxJ265mADgwmvLI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@ -5,8 +5,10 @@ import (
"errors"
"fmt"
"github.com/Mahdi-zarei/sing-box-extra/boxbox"
"github.com/Mahdi-zarei/sing-box-extra/boxdns"
"github.com/sagernet/sing-box/common/settings"
"github.com/sagernet/sing/common/metadata"
"net/netip"
"strings"
"time"
@ -237,3 +239,37 @@ func (s *server) SetSystemProxy(ctx context.Context, in *gen.SetSystemProxyReque
return &gen.EmptyResp{}, nil
}
func (s *server) GetSystemDNS(ctx context.Context, in *gen.EmptyReq) (*gen.GetSystemDNSResponse, error) {
servers, dhcp, err := boxdns.GetDefaultDNS()
if err != nil {
return nil, err
}
stringServers := make([]string, 0)
for _, server := range servers {
stringServers = append(stringServers, server.String())
}
return &gen.GetSystemDNSResponse{
Servers: stringServers,
IsDhcp: dhcp,
}, nil
}
func (s *server) SetSystemDNS(ctx context.Context, in *gen.SetSystemDNSRequest) (*gen.EmptyResp, error) {
var servers []netip.Addr
for _, server := range in.Servers {
s, err := netip.ParseAddr(server)
if err != nil {
return nil, err
}
servers = append(servers, s)
}
err := boxdns.SetDefaultDNS(servers, in.SetDhcp, in.Clear)
if err != nil {
return nil, err
}
return &gen.EmptyResp{}, nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc v5.26.1
// protoc-gen-go v1.33.0
// protoc v5.28.2
// source: libcore.proto
package gen
@ -991,6 +991,124 @@ func (x *SetSystemProxyRequest) GetAddress() string {
return ""
}
type SetSystemDNSRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Clear bool `protobuf:"varint,1,opt,name=clear,proto3" json:"clear,omitempty"`
Servers []string `protobuf:"bytes,2,rep,name=servers,proto3" json:"servers,omitempty"`
SetDhcp bool `protobuf:"varint,3,opt,name=set_dhcp,json=setDhcp,proto3" json:"set_dhcp,omitempty"`
}
func (x *SetSystemDNSRequest) Reset() {
*x = SetSystemDNSRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_libcore_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SetSystemDNSRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SetSystemDNSRequest) ProtoMessage() {}
func (x *SetSystemDNSRequest) ProtoReflect() protoreflect.Message {
mi := &file_libcore_proto_msgTypes[17]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SetSystemDNSRequest.ProtoReflect.Descriptor instead.
func (*SetSystemDNSRequest) Descriptor() ([]byte, []int) {
return file_libcore_proto_rawDescGZIP(), []int{17}
}
func (x *SetSystemDNSRequest) GetClear() bool {
if x != nil {
return x.Clear
}
return false
}
func (x *SetSystemDNSRequest) GetServers() []string {
if x != nil {
return x.Servers
}
return nil
}
func (x *SetSystemDNSRequest) GetSetDhcp() bool {
if x != nil {
return x.SetDhcp
}
return false
}
type GetSystemDNSResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Servers []string `protobuf:"bytes,1,rep,name=servers,proto3" json:"servers,omitempty"`
IsDhcp bool `protobuf:"varint,2,opt,name=is_dhcp,json=isDhcp,proto3" json:"is_dhcp,omitempty"`
}
func (x *GetSystemDNSResponse) Reset() {
*x = GetSystemDNSResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_libcore_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetSystemDNSResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetSystemDNSResponse) ProtoMessage() {}
func (x *GetSystemDNSResponse) ProtoReflect() protoreflect.Message {
mi := &file_libcore_proto_msgTypes[18]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetSystemDNSResponse.ProtoReflect.Descriptor instead.
func (*GetSystemDNSResponse) Descriptor() ([]byte, []int) {
return file_libcore_proto_rawDescGZIP(), []int{18}
}
func (x *GetSystemDNSResponse) GetServers() []string {
if x != nil {
return x.Servers
}
return nil
}
func (x *GetSystemDNSResponse) GetIsDhcp() bool {
if x != nil {
return x.IsDhcp
}
return false
}
var File_libcore_proto protoreflect.FileDescriptor
var file_libcore_proto_rawDesc = []byte{
@ -1082,63 +1200,82 @@ var file_libcore_proto_rawDesc = []byte{
0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x65,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x65, 0x6e, 0x61,
0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2a, 0x27, 0x0a,
0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x09, 0x0a,
0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e,
0x6c, 0x6f, 0x61, 0x64, 0x10, 0x01, 0x32, 0xb1, 0x06, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x63, 0x6f,
0x72, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x45, 0x78, 0x69,
0x74, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74,
0x79, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45,
0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x06, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x12, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f,
0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12,
0x35, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f,
0x72, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71,
0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x11,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x60, 0x0a,
0x13, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x18, 0x01, 0x20,
0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65,
0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72,
0x76, 0x65, 0x72, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x5f, 0x64, 0x68, 0x63, 0x70,
0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x65, 0x74, 0x44, 0x68, 0x63, 0x70, 0x22,
0x49, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65,
0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
0x73, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x73, 0x5f, 0x64, 0x68, 0x63, 0x70, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x44, 0x68, 0x63, 0x70, 0x2a, 0x27, 0x0a, 0x0c, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61,
0x64, 0x10, 0x01, 0x32, 0xb5, 0x07, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x45, 0x78, 0x69, 0x74, 0x12, 0x11,
0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65,
0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f,
0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2d, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12,
0x10, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65,
0x71, 0x1a, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74,
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x08, 0x53, 0x74, 0x6f, 0x70, 0x54, 0x65,
0x73, 0x74, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70,
0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3f, 0x0a, 0x0a, 0x51, 0x75, 0x65,
0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a,
0x17, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53,
0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0f, 0x4c, 0x69,
0x73, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x11, 0x2e,
0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74,
0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x12, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x05,
0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e,
0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e,
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73,
0x70, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x11, 0x2e, 0x6c, 0x69,
0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x12,
0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65,
0x73, 0x70, 0x22, 0x00, 0x12, 0x2d, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x10, 0x2e, 0x6c,
0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x11,
0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73,
0x70, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x08, 0x53, 0x74, 0x6f, 0x70, 0x54, 0x65, 0x73, 0x74, 0x12,
0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52,
0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70,
0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3f, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53,
0x74, 0x61, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x51,
0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6c,
0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74,
0x73, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x43,
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62,
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e,
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x40, 0x0a,
0x0c, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x11, 0x2e,
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71,
0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43,
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00,
0x12, 0x40, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73, 0x74,
0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65,
0x74, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x44, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65,
0x4c, 0x69, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45,
0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1f, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x70,
0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12, 0x21, 0x2e,
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47,
0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x52, 0x65, 0x73, 0x70, 0x12, 0x4e, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47,
0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12, 0x23, 0x2e, 0x6c, 0x69,
0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f,
0x53, 0x69, 0x74, 0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x52, 0x65, 0x73, 0x70, 0x12, 0x44, 0x0a, 0x0e, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65,
0x6d, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1e, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
0x2e, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x72,
0x70, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x6e, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x65,
0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x44, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73,
0x74, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74,
0x79, 0x52, 0x65, 0x71, 0x1a, 0x1f, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47,
0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65,
0x47, 0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12, 0x21, 0x2e, 0x6c, 0x69, 0x62,
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f, 0x49,
0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e,
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73,
0x70, 0x12, 0x4e, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f, 0x53,
0x69, 0x74, 0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12, 0x23, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f,
0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74,
0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e,
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73,
0x70, 0x12, 0x44, 0x0a, 0x0e, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x72,
0x6f, 0x78, 0x79, 0x12, 0x1e, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65,
0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d,
0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x40, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x53, 0x79,
0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x62,
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e,
0x53, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x0c, 0x53, 0x65, 0x74,
0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x62, 0x63,
0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x42, 0x11, 0x5a, 0x0f, 0x67,
0x72, 0x70, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x6e, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1154,7 +1291,7 @@ func file_libcore_proto_rawDescGZIP() []byte {
}
var file_libcore_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_libcore_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
var file_libcore_proto_msgTypes = make([]protoimpl.MessageInfo, 19)
var file_libcore_proto_goTypes = []interface{}{
(UpdateAction)(0), // 0: libcore.UpdateAction
(*EmptyReq)(nil), // 1: libcore.EmptyReq
@ -1174,6 +1311,8 @@ var file_libcore_proto_goTypes = []interface{}{
(*CompileGeoIPToSrsRequest)(nil), // 15: libcore.CompileGeoIPToSrsRequest
(*CompileGeoSiteToSrsRequest)(nil), // 16: libcore.CompileGeoSiteToSrsRequest
(*SetSystemProxyRequest)(nil), // 17: libcore.SetSystemProxyRequest
(*SetSystemDNSRequest)(nil), // 18: libcore.SetSystemDNSRequest
(*GetSystemDNSResponse)(nil), // 19: libcore.GetSystemDNSResponse
}
var file_libcore_proto_depIdxs = []int32{
5, // 0: libcore.TestResp.results:type_name -> libcore.URLTestResp
@ -1191,21 +1330,25 @@ var file_libcore_proto_depIdxs = []int32{
15, // 12: libcore.LibcoreService.CompileGeoIPToSrs:input_type -> libcore.CompileGeoIPToSrsRequest
16, // 13: libcore.LibcoreService.CompileGeoSiteToSrs:input_type -> libcore.CompileGeoSiteToSrsRequest
17, // 14: libcore.LibcoreService.SetSystemProxy:input_type -> libcore.SetSystemProxyRequest
2, // 15: libcore.LibcoreService.Exit:output_type -> libcore.EmptyResp
11, // 16: libcore.LibcoreService.Update:output_type -> libcore.UpdateResp
3, // 17: libcore.LibcoreService.Start:output_type -> libcore.ErrorResp
3, // 18: libcore.LibcoreService.Stop:output_type -> libcore.ErrorResp
7, // 19: libcore.LibcoreService.Test:output_type -> libcore.TestResp
2, // 20: libcore.LibcoreService.StopTest:output_type -> libcore.EmptyResp
9, // 21: libcore.LibcoreService.QueryStats:output_type -> libcore.QueryStatsResp
12, // 22: libcore.LibcoreService.ListConnections:output_type -> libcore.ListConnectionsResp
13, // 23: libcore.LibcoreService.GetGeoIPList:output_type -> libcore.GetGeoIPListResponse
14, // 24: libcore.LibcoreService.GetGeoSiteList:output_type -> libcore.GetGeoSiteListResponse
2, // 25: libcore.LibcoreService.CompileGeoIPToSrs:output_type -> libcore.EmptyResp
2, // 26: libcore.LibcoreService.CompileGeoSiteToSrs:output_type -> libcore.EmptyResp
2, // 27: libcore.LibcoreService.SetSystemProxy:output_type -> libcore.EmptyResp
15, // [15:28] is the sub-list for method output_type
2, // [2:15] is the sub-list for method input_type
1, // 15: libcore.LibcoreService.GetSystemDNS:input_type -> libcore.EmptyReq
18, // 16: libcore.LibcoreService.SetSystemDNS:input_type -> libcore.SetSystemDNSRequest
2, // 17: libcore.LibcoreService.Exit:output_type -> libcore.EmptyResp
11, // 18: libcore.LibcoreService.Update:output_type -> libcore.UpdateResp
3, // 19: libcore.LibcoreService.Start:output_type -> libcore.ErrorResp
3, // 20: libcore.LibcoreService.Stop:output_type -> libcore.ErrorResp
7, // 21: libcore.LibcoreService.Test:output_type -> libcore.TestResp
2, // 22: libcore.LibcoreService.StopTest:output_type -> libcore.EmptyResp
9, // 23: libcore.LibcoreService.QueryStats:output_type -> libcore.QueryStatsResp
12, // 24: libcore.LibcoreService.ListConnections:output_type -> libcore.ListConnectionsResp
13, // 25: libcore.LibcoreService.GetGeoIPList:output_type -> libcore.GetGeoIPListResponse
14, // 26: libcore.LibcoreService.GetGeoSiteList:output_type -> libcore.GetGeoSiteListResponse
2, // 27: libcore.LibcoreService.CompileGeoIPToSrs:output_type -> libcore.EmptyResp
2, // 28: libcore.LibcoreService.CompileGeoSiteToSrs:output_type -> libcore.EmptyResp
2, // 29: libcore.LibcoreService.SetSystemProxy:output_type -> libcore.EmptyResp
19, // 30: libcore.LibcoreService.GetSystemDNS:output_type -> libcore.GetSystemDNSResponse
2, // 31: libcore.LibcoreService.SetSystemDNS:output_type -> libcore.EmptyResp
17, // [17:32] is the sub-list for method output_type
2, // [2:17] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
@ -1421,6 +1564,30 @@ func file_libcore_proto_init() {
return nil
}
}
file_libcore_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SetSystemDNSRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_libcore_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetSystemDNSResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -1428,7 +1595,7 @@ func file_libcore_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_libcore_proto_rawDesc,
NumEnums: 1,
NumMessages: 17,
NumMessages: 19,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -20,6 +20,9 @@ service LibcoreService {
rpc CompileGeoSiteToSrs(CompileGeoSiteToSrsRequest) returns (EmptyResp);
//
rpc SetSystemProxy(SetSystemProxyRequest) returns (EmptyResp);
//
rpc GetSystemDNS(EmptyReq) returns (GetSystemDNSResponse);
rpc SetSystemDNS(SetSystemDNSRequest) returns (EmptyResp);
}
message EmptyReq {}
@ -107,4 +110,15 @@ message CompileGeoSiteToSrsRequest {
message SetSystemProxyRequest {
bool enable = 1;
string address = 2;
}
message SetSystemDNSRequest {
bool clear = 1;
repeated string servers = 2;
bool set_dhcp = 3;
}
message GetSystemDNSResponse {
repeated string servers = 1;
bool is_dhcp = 2;
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v5.26.1
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.28.2
// source: libcore.proto
package gen
@ -15,8 +15,8 @@ import (
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
LibcoreService_Exit_FullMethodName = "/libcore.LibcoreService/Exit"
@ -32,6 +32,8 @@ const (
LibcoreService_CompileGeoIPToSrs_FullMethodName = "/libcore.LibcoreService/CompileGeoIPToSrs"
LibcoreService_CompileGeoSiteToSrs_FullMethodName = "/libcore.LibcoreService/CompileGeoSiteToSrs"
LibcoreService_SetSystemProxy_FullMethodName = "/libcore.LibcoreService/SetSystemProxy"
LibcoreService_GetSystemDNS_FullMethodName = "/libcore.LibcoreService/GetSystemDNS"
LibcoreService_SetSystemDNS_FullMethodName = "/libcore.LibcoreService/SetSystemDNS"
)
// LibcoreServiceClient is the client API for LibcoreService service.
@ -51,6 +53,8 @@ type LibcoreServiceClient interface {
CompileGeoIPToSrs(ctx context.Context, in *CompileGeoIPToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error)
CompileGeoSiteToSrs(ctx context.Context, in *CompileGeoSiteToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error)
SetSystemProxy(ctx context.Context, in *SetSystemProxyRequest, opts ...grpc.CallOption) (*EmptyResp, error)
GetSystemDNS(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetSystemDNSResponse, error)
SetSystemDNS(ctx context.Context, in *SetSystemDNSRequest, opts ...grpc.CallOption) (*EmptyResp, error)
}
type libcoreServiceClient struct {
@ -62,8 +66,9 @@ func NewLibcoreServiceClient(cc grpc.ClientConnInterface) LibcoreServiceClient {
}
func (c *libcoreServiceClient) Exit(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*EmptyResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EmptyResp)
err := c.cc.Invoke(ctx, LibcoreService_Exit_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_Exit_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -71,8 +76,9 @@ func (c *libcoreServiceClient) Exit(ctx context.Context, in *EmptyReq, opts ...g
}
func (c *libcoreServiceClient) Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*UpdateResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(UpdateResp)
err := c.cc.Invoke(ctx, LibcoreService_Update_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_Update_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -80,8 +86,9 @@ func (c *libcoreServiceClient) Update(ctx context.Context, in *UpdateReq, opts .
}
func (c *libcoreServiceClient) Start(ctx context.Context, in *LoadConfigReq, opts ...grpc.CallOption) (*ErrorResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ErrorResp)
err := c.cc.Invoke(ctx, LibcoreService_Start_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_Start_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -89,8 +96,9 @@ func (c *libcoreServiceClient) Start(ctx context.Context, in *LoadConfigReq, opt
}
func (c *libcoreServiceClient) Stop(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*ErrorResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ErrorResp)
err := c.cc.Invoke(ctx, LibcoreService_Stop_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_Stop_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -98,8 +106,9 @@ func (c *libcoreServiceClient) Stop(ctx context.Context, in *EmptyReq, opts ...g
}
func (c *libcoreServiceClient) Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*TestResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(TestResp)
err := c.cc.Invoke(ctx, LibcoreService_Test_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_Test_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -107,8 +116,9 @@ func (c *libcoreServiceClient) Test(ctx context.Context, in *TestReq, opts ...gr
}
func (c *libcoreServiceClient) StopTest(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*EmptyResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EmptyResp)
err := c.cc.Invoke(ctx, LibcoreService_StopTest_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_StopTest_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -116,8 +126,9 @@ func (c *libcoreServiceClient) StopTest(ctx context.Context, in *EmptyReq, opts
}
func (c *libcoreServiceClient) QueryStats(ctx context.Context, in *QueryStatsReq, opts ...grpc.CallOption) (*QueryStatsResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(QueryStatsResp)
err := c.cc.Invoke(ctx, LibcoreService_QueryStats_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_QueryStats_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -125,8 +136,9 @@ func (c *libcoreServiceClient) QueryStats(ctx context.Context, in *QueryStatsReq
}
func (c *libcoreServiceClient) ListConnections(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*ListConnectionsResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListConnectionsResp)
err := c.cc.Invoke(ctx, LibcoreService_ListConnections_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_ListConnections_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -134,8 +146,9 @@ func (c *libcoreServiceClient) ListConnections(ctx context.Context, in *EmptyReq
}
func (c *libcoreServiceClient) GetGeoIPList(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetGeoIPListResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetGeoIPListResponse)
err := c.cc.Invoke(ctx, LibcoreService_GetGeoIPList_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_GetGeoIPList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -143,8 +156,9 @@ func (c *libcoreServiceClient) GetGeoIPList(ctx context.Context, in *EmptyReq, o
}
func (c *libcoreServiceClient) GetGeoSiteList(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetGeoSiteListResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetGeoSiteListResponse)
err := c.cc.Invoke(ctx, LibcoreService_GetGeoSiteList_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_GetGeoSiteList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -152,8 +166,9 @@ func (c *libcoreServiceClient) GetGeoSiteList(ctx context.Context, in *EmptyReq,
}
func (c *libcoreServiceClient) CompileGeoIPToSrs(ctx context.Context, in *CompileGeoIPToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EmptyResp)
err := c.cc.Invoke(ctx, LibcoreService_CompileGeoIPToSrs_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_CompileGeoIPToSrs_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -161,8 +176,9 @@ func (c *libcoreServiceClient) CompileGeoIPToSrs(ctx context.Context, in *Compil
}
func (c *libcoreServiceClient) CompileGeoSiteToSrs(ctx context.Context, in *CompileGeoSiteToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EmptyResp)
err := c.cc.Invoke(ctx, LibcoreService_CompileGeoSiteToSrs_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_CompileGeoSiteToSrs_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -170,8 +186,29 @@ func (c *libcoreServiceClient) CompileGeoSiteToSrs(ctx context.Context, in *Comp
}
func (c *libcoreServiceClient) SetSystemProxy(ctx context.Context, in *SetSystemProxyRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EmptyResp)
err := c.cc.Invoke(ctx, LibcoreService_SetSystemProxy_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, LibcoreService_SetSystemProxy_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *libcoreServiceClient) GetSystemDNS(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetSystemDNSResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetSystemDNSResponse)
err := c.cc.Invoke(ctx, LibcoreService_GetSystemDNS_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *libcoreServiceClient) SetSystemDNS(ctx context.Context, in *SetSystemDNSRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EmptyResp)
err := c.cc.Invoke(ctx, LibcoreService_SetSystemDNS_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@ -180,7 +217,7 @@ func (c *libcoreServiceClient) SetSystemProxy(ctx context.Context, in *SetSystem
// LibcoreServiceServer is the server API for LibcoreService service.
// All implementations must embed UnimplementedLibcoreServiceServer
// for forward compatibility
// for forward compatibility.
type LibcoreServiceServer interface {
Exit(context.Context, *EmptyReq) (*EmptyResp, error)
Update(context.Context, *UpdateReq) (*UpdateResp, error)
@ -195,12 +232,17 @@ type LibcoreServiceServer interface {
CompileGeoIPToSrs(context.Context, *CompileGeoIPToSrsRequest) (*EmptyResp, error)
CompileGeoSiteToSrs(context.Context, *CompileGeoSiteToSrsRequest) (*EmptyResp, error)
SetSystemProxy(context.Context, *SetSystemProxyRequest) (*EmptyResp, error)
GetSystemDNS(context.Context, *EmptyReq) (*GetSystemDNSResponse, error)
SetSystemDNS(context.Context, *SetSystemDNSRequest) (*EmptyResp, error)
mustEmbedUnimplementedLibcoreServiceServer()
}
// UnimplementedLibcoreServiceServer must be embedded to have forward compatible implementations.
type UnimplementedLibcoreServiceServer struct {
}
// UnimplementedLibcoreServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedLibcoreServiceServer struct{}
func (UnimplementedLibcoreServiceServer) Exit(context.Context, *EmptyReq) (*EmptyResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Exit not implemented")
@ -241,7 +283,14 @@ func (UnimplementedLibcoreServiceServer) CompileGeoSiteToSrs(context.Context, *C
func (UnimplementedLibcoreServiceServer) SetSystemProxy(context.Context, *SetSystemProxyRequest) (*EmptyResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetSystemProxy not implemented")
}
func (UnimplementedLibcoreServiceServer) GetSystemDNS(context.Context, *EmptyReq) (*GetSystemDNSResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSystemDNS not implemented")
}
func (UnimplementedLibcoreServiceServer) SetSystemDNS(context.Context, *SetSystemDNSRequest) (*EmptyResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetSystemDNS not implemented")
}
func (UnimplementedLibcoreServiceServer) mustEmbedUnimplementedLibcoreServiceServer() {}
func (UnimplementedLibcoreServiceServer) testEmbeddedByValue() {}
// UnsafeLibcoreServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LibcoreServiceServer will
@ -251,6 +300,13 @@ type UnsafeLibcoreServiceServer interface {
}
func RegisterLibcoreServiceServer(s grpc.ServiceRegistrar, srv LibcoreServiceServer) {
// If the following call pancis, it indicates UnimplementedLibcoreServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&LibcoreService_ServiceDesc, srv)
}
@ -488,6 +544,42 @@ func _LibcoreService_SetSystemProxy_Handler(srv interface{}, ctx context.Context
return interceptor(ctx, in, info, handler)
}
func _LibcoreService_GetSystemDNS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EmptyReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibcoreServiceServer).GetSystemDNS(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LibcoreService_GetSystemDNS_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibcoreServiceServer).GetSystemDNS(ctx, req.(*EmptyReq))
}
return interceptor(ctx, in, info, handler)
}
func _LibcoreService_SetSystemDNS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SetSystemDNSRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LibcoreServiceServer).SetSystemDNS(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LibcoreService_SetSystemDNS_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LibcoreServiceServer).SetSystemDNS(ctx, req.(*SetSystemDNSRequest))
}
return interceptor(ctx, in, info, handler)
}
// LibcoreService_ServiceDesc is the grpc.ServiceDesc for LibcoreService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -547,6 +639,14 @@ var LibcoreService_ServiceDesc = grpc.ServiceDesc{
MethodName: "SetSystemProxy",
Handler: _LibcoreService_SetSystemProxy_Handler,
},
{
MethodName: "GetSystemDNS",
Handler: _LibcoreService_GetSystemDNS_Handler,
},
{
MethodName: "SetSystemDNS",
Handler: _LibcoreService_SetSystemDNS_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "libcore.proto",

View File

@ -1,19 +1,19 @@
module grpc_server
go 1.19
go 1.21
require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/matsuridayo/libneko v0.0.0-20230913024055-5277a5bfc889
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.33.0
google.golang.org/grpc v1.67.0
google.golang.org/protobuf v1.34.2
)
require (
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
)
replace cloud.google.com/go => cloud.google.com/go v0.112.2
replace cloud.google.com/go => cloud.google.com/go v0.115.1

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
#pragma once
#include <QString>
namespace NekoGui {
namespace DomainMatcher {
@ -21,4 +22,8 @@ namespace NekoGui {
SING_BOX,
};
}
namespace Information {
inline QString HijackInfo = "Listens on the given addr:port (on Windows, port is always 53) and redirects the requests to the DNS module. Domains that match the rules will have their requests hijacked and the A and AAAA queries will be responded with the Inet4 response and Inet6 response respectively.\nThe Redirect settings sets up an inbound that listens on the given addr:port, sniffs the destination if possible and redirects the requests to their true destination.\nThe use case of these settings is apps that do not respect the system proxy for resolving their DNS requests (one such example is discord), You can hijack their DNS requests to 127.0.0.1 and then route them through the Nekoray tunnel. The same effect could be achieved using Tun mode, but one may not want to tunnel the whole device (For example when Gaming), this is where DNS hijack can transparently handle things.\n\nCurrently you can Automatically set the System DNS in windows.";
}
} // namespace NekoGui

View File

@ -73,9 +73,7 @@ namespace NekoGui_ConfigItem {
switch (item->type) {
case itemType::string:
// Allow Empty
if (!((QString *) item->ptr)->isEmpty()) {
object.insert(item->name, *(QString *) item->ptr);
}
object.insert(item->name, *(QString *) item->ptr);
break;
case itemType::integer:
object.insert(item->name, *(int *) item->ptr);
@ -304,6 +302,9 @@ namespace NekoGui {
_add(new configItem("enable_redirect", &enable_redirect, itemType::boolean));
_add(new configItem("redirect_listen_address", &redirect_listen_address, itemType::string));
_add(new configItem("redirect_listen_port", &redirect_listen_port, itemType::integer));
_add(new configItem("system_dns_set", &system_dns_set, itemType::boolean));
_add(new configItem("is_dhcp", &is_dhcp, itemType::boolean));
_add(new configItem("system_dns_servers", &system_dns_servers, itemType::stringList));
}
void DataStore::UpdateStartedId(int id) {

View File

@ -149,6 +149,11 @@ namespace NekoGui {
QString redirect_listen_address = "127.0.0.1";
int redirect_listen_port = 443;
// System dns
bool system_dns_set = false;
bool is_dhcp = false;
QStringList system_dns_servers = {};
// Hotkey
QString hotkey_mainwindow = "";
QString hotkey_group = "";

View File

@ -6,7 +6,6 @@
#include "main/NekoGui.hpp"
#include <QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
#include <QtEndian>
@ -381,4 +380,38 @@ namespace NekoGui_rpc {
}
}
libcore::GetSystemDNSResponse Client::GetSystemDNS(bool *rpcOK) const {
libcore::EmptyReq req;
libcore::GetSystemDNSResponse resp;
auto status = default_grpc_channel->Call("GetSystemDNS", req, &resp);
if (status == QNetworkReply::NoError) {
*rpcOK = true;
return resp;
} else {
NOT_OK
return {};
}
}
QString Client::SetSystemDNS(bool *rpcOK, const QStringList& servers, const bool dhcp, const bool clear) const {
libcore::SetSystemDNSRequest req;
libcore::EmptyResp resp;
for (const auto& server : servers) {
req.add_servers(server.toStdString());
}
req.set_set_dhcp(dhcp);
req.set_clear(clear);
auto status = default_grpc_channel->Call("SetSystemDNS", req, &resp);
if (status == QNetworkReply::NoError) {
*rpcOK = true;
return "";
} else {
NOT_OK
return qt_error_string(status);
}
}
} // namespace NekoGui_rpc

View File

@ -38,6 +38,10 @@ namespace NekoGui_rpc {
QString SetSystemProxy(bool *rpcOK, bool enable);
libcore::GetSystemDNSResponse GetSystemDNS(bool *rpcOK) const;
QString SetSystemDNS(bool *rpcOK, const QStringList& servers, bool dhcp, bool clear) const;
private:
std::function<std::unique_ptr<QtGrpc::Http2GrpcChannelPrivate>()> make_grpc_channel;
std::unique_ptr<QtGrpc::Http2GrpcChannelPrivate> default_grpc_channel;

View File

@ -9,6 +9,7 @@
#include <QFile>
#include <QMessageBox>
#include <QShortcut>
#include <rpc/gRPC.h>
void DialogManageRoutes::reloadProfileItems() {
if (chainList.empty()) {
@ -129,9 +130,25 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne
ui->dnshijack_listenaddr->setText(NekoGui::dataStore->dns_server_listen_addr);
ui->dnshijack_listenport->setValidator(QRegExpValidator_Number);
ui->dnshijack_listenport->setText(Int2String(NekoGui::dataStore->dns_server_listen_port));
ui->dnshijack_rules->setText(NekoGui::dataStore->dns_server_rules.join("\n"));
ui->dnshijack_v4resp->setText(NekoGui::dataStore->dns_v4_resp);
ui->dnshijack_v6resp->setText(NekoGui::dataStore->dns_v6_resp);
connect(ui->dnshijack_what, &QPushButton::clicked, this, [=] {
MessageBoxInfo("What is this?", NekoGui::Information::HijackInfo);
});
bool ok;
auto geoIpList = NekoGui_rpc::defaultClient->GetGeoList(&ok, NekoGui_rpc::GeoRuleSetType::ip);
auto geoSiteList = NekoGui_rpc::defaultClient->GetGeoList(&ok, NekoGui_rpc::GeoRuleSetType::site);
QStringList ruleItems = {"domain:", "suffix:", "regex:"};
for (const auto& geoIP : geoIpList) {
ruleItems.append("rule_set:"+geoIP);
}
for (const auto& geoSite: geoSiteList) {
ruleItems.append("rule_set:"+geoSite);
}
rule_editor = new AutoCompleteTextEdit("", ruleItems, this);
ui->hijack_box->layout()->replaceWidget(ui->dnshijack_rules, rule_editor);
rule_editor->setPlainText(NekoGui::dataStore->dns_server_rules.join("\n"));
#ifndef Q_OS_LINUX
ui->dnshijack_listenport->setVisible(false);
ui->dnshijack_listenport_l->setVisible(false);
@ -194,7 +211,7 @@ void DialogManageRoutes::accept() {
NekoGui::dataStore->dns_server_listen_port = ui->dnshijack_listenport->text().toInt();
NekoGui::dataStore->dns_v4_resp = ui->dnshijack_v4resp->text();
NekoGui::dataStore->dns_v6_resp = ui->dnshijack_v6resp->text();
auto rawRules = ui->dnshijack_rules->toPlainText().split("\n");
auto rawRules = rule_editor->toPlainText().split("\n");
QStringList dnsRules;
for (const auto& rawRule : rawRules) {
if (rawRule.trimmed().isEmpty()) continue;

View File

@ -37,6 +37,8 @@ private:
static bool validate_dns_rules(const QString &rawString);
QShortcut* deleteShortcut;
AutoCompleteTextEdit* rule_editor;
public slots:
void accept() override;

View File

@ -138,7 +138,7 @@ also if the connection cannot be established with the current address family (ip
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="hijack_box">
<property name="title">
<string>DNS Server</string>
</property>
@ -179,6 +179,9 @@ also if the connection cannot be established with the current address family (ip
</item>
<item row="5" column="0">
<widget class="QLabel" name="dnshijack_rules_l">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Following format should be used:&lt;br/&gt;domain:a.com&lt;/p&gt;&lt;p&gt;suffix:a.com&lt;/p&gt;&lt;p&gt;regex:someregex&lt;/p&gt;&lt;p&gt;rule_set:nameOfRuleSet&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Rules</string>
</property>

View File

@ -324,6 +324,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
neko_set_spmode_vpn(false);
});
connect(ui->menu_qr, &QAction::triggered, this, [=]() { display_qr_link(false); });
connect(ui->system_dns, &QCheckBox::clicked, this, [=](bool checked) {
if (const auto ok = set_system_dns(checked); !ok) {
ui->system_dns->setChecked(!checked);
}
});
connect(ui->menu_server, &QMenu::aboutToShow, this, [=](){
if (!speedtestRunning.tryLock()) {
@ -571,8 +576,11 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
neko_set_spmode_vpn(true, false);
}
}
neko_start(info.split(",")[1].toInt());
if (NekoGui::dataStore->system_dns_set) {
set_system_dns(true);
ui->system_dns->setChecked(true);
}
}
}
}
@ -612,6 +620,9 @@ void MainWindow::on_menu_hotkey_settings_triggered() {
}
void MainWindow::on_commitDataRequest() {
qDebug() << "Handling DNS setting";
if (NekoGui::dataStore->system_dns_set) set_system_dns(false, false);
qDebug() << "Done handling DNS setting";
qDebug() << "Start of data save";
//
if (!isMaximized()) {

View File

@ -208,6 +208,8 @@ private:
static void stop_core_daemon();
static bool set_system_dns(bool set, bool save_set = true);
void CheckUpdate();
protected:

View File

@ -126,6 +126,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="system_dns">
<property name="text">
<string>System DNS</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_SystemProxy">
<property name="text">
@ -337,7 +344,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>25</height>
<height>17</height>
</rect>
</property>
<widget class="QMenu" name="menu_program">

View File

@ -207,6 +207,39 @@ void MainWindow::stop_core_daemon() {
NekoGui_rpc::defaultClient->Exit();
}
bool MainWindow::set_system_dns(bool set, bool save_set) {
bool rpcOK;
QStringList servers;
bool is_dhcp = false;
QString res;
if (set) {
bool ok;
auto sysDefaults = defaultClient->GetSystemDNS(&ok);
if (!ok) {
MW_show_log("Failed to get system dns settings");
return false;
}
QStringList sysDefServers;
for (const auto& server : sysDefaults.servers()) {
sysDefServers.append(server.c_str());
}
NekoGui::dataStore->system_dns_servers = sysDefServers;
NekoGui::dataStore->is_dhcp = sysDefaults.is_dhcp();
servers = {NekoGui::dataStore->dns_server_listen_addr};
res = defaultClient->SetSystemDNS(&rpcOK, servers, is_dhcp, false);
} else {
servers = NekoGui::dataStore->system_dns_servers;
is_dhcp = NekoGui::dataStore->is_dhcp;
res = defaultClient->SetSystemDNS(&rpcOK, servers, is_dhcp, true);
}
if (!rpcOK) {
MW_show_log("Failed to set system dns: " + res);
return false;
}
if (save_set) NekoGui::dataStore->system_dns_set = set;
return true;
}
void MainWindow::neko_start(int _id) {
if (NekoGui::dataStore->prepare_exit) return;