mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-25 02:50:06 +08:00
core: prepare for renaming
This commit is contained in:
parent
80466c7aef
commit
556c8c418b
2
core/.gitignore
vendored
2
core/.gitignore
vendored
@ -3,6 +3,4 @@
|
|||||||
*.json
|
*.json
|
||||||
*.exe
|
*.exe
|
||||||
*.dat
|
*.dat
|
||||||
/cmd/nekoray_core/nekoray_core
|
|
||||||
/cmd/nekobox_core/nekobox_core
|
|
||||||
*.db
|
*.db
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
package boxapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"github.com/sagernet/sing-box/common/dialer"
|
|
||||||
"github.com/sagernet/sing/common/metadata"
|
|
||||||
"nekobox_core/internal/boxbox"
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
func DialContext(ctx context.Context, box *boxbox.Box, network, addr string) (net.Conn, error) {
|
|
||||||
conn, err := dialer.NewDefaultOutbound(box.Outbound()).DialContext(ctx, network, metadata.ParseSocksaddr(addr))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return conn, nil
|
|
||||||
}
|
|
||||||
@ -25,7 +25,7 @@ var dnsIsSet bool
|
|||||||
|
|
||||||
func (d *DnsManager) HandleSystemDNS(ifc *control.Interface, flag int) {
|
func (d *DnsManager) HandleSystemDNS(ifc *control.Interface, flag int) {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
log.Println("No DnsManager, you may need to restart nekoray")
|
log.Println("No DnsManager, you may need to restart Throne")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ifc != nil {
|
if ifc != nil {
|
||||||
@ -42,7 +42,7 @@ func (d *DnsManager) HandleSystemDNS(ifc *control.Interface, flag int) {
|
|||||||
|
|
||||||
func (d *DnsManager) getInterfaceGuid(ifc control.Interface) (string, error) {
|
func (d *DnsManager) getInterfaceGuid(ifc control.Interface) (string, error) {
|
||||||
if d.Monitor == nil {
|
if d.Monitor == nil {
|
||||||
return "", E.New("No Dns Manager, you may need to restart nekoray")
|
return "", E.New("No Dns Manager, you may need to restart Throne")
|
||||||
}
|
}
|
||||||
index := ifc.Index
|
index := ifc.Index
|
||||||
u, err := ifcIdxtoUUID(index)
|
u, err := ifcIdxtoUUID(index)
|
||||||
@ -83,8 +83,8 @@ func ifcIdxtoUUID(index int) (*uuid.UUID, error) {
|
|||||||
|
|
||||||
func (d *DnsManager) isIfcDNSDhcp(ifc control.Interface) (dhcp bool, err error) {
|
func (d *DnsManager) isIfcDNSDhcp(ifc control.Interface) (dhcp bool, err error) {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
log.Println("No DnsManager, you may need to restart nekoray")
|
log.Println("No DnsManager, you may need to restart Throne")
|
||||||
return false, E.New("No Dns Manager, you may need to restart nekoray")
|
return false, E.New("No Dns Manager, you may need to restart Throne")
|
||||||
}
|
}
|
||||||
|
|
||||||
luid, err := winipcfg.LUIDFromIndex(uint32(ifc.Index))
|
luid, err := winipcfg.LUIDFromIndex(uint32(ifc.Index))
|
||||||
@ -226,8 +226,8 @@ func (d *DnsManager) setSystemDNS(ifx control.Interface) {
|
|||||||
|
|
||||||
func (d *DnsManager) SetSystemDNS(ifc *control.Interface, clear bool) error {
|
func (d *DnsManager) SetSystemDNS(ifc *control.Interface, clear bool) error {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
log.Println("No DnsManager, you may need to restart nekoray")
|
log.Println("No DnsManager, you may need to restart Throne")
|
||||||
return E.New("No dns Manager, you may need to restart nekoray")
|
return E.New("No dns Manager, you may need to restart Throne")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ifc == nil {
|
if ifc == nil {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ type DnsManager struct {
|
|||||||
|
|
||||||
func (d *DnsManager) HandleUnderlyingDNS(ifc *control.Interface, flag int) {
|
func (d *DnsManager) HandleUnderlyingDNS(ifc *control.Interface, flag int) {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
log.Println("No DnsManager, you may need to restart nekoray")
|
log.Println("No DnsManager, you may need to restart Throne")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ifc == nil {
|
if ifc == nil {
|
||||||
|
|||||||
@ -30,9 +30,9 @@ func main() {
|
|||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
Updater()
|
Updater()
|
||||||
// 3. start
|
// 3. start
|
||||||
exec.Command("./nekoray.exe").Start()
|
exec.Command("./Throne.exe").Start()
|
||||||
} else {
|
} else {
|
||||||
// 1. nekoray stop itself and run "updater.exe"
|
// 1. Throne stop itself and run "updater.exe"
|
||||||
Copy("./updater.exe", "./updater.old")
|
Copy("./updater.exe", "./updater.old")
|
||||||
exec.Command("./updater.old", os.Args[1:]...).Start()
|
exec.Command("./updater.old", os.Args[1:]...).Start()
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ func main() {
|
|||||||
// 1. update files
|
// 1. update files
|
||||||
Updater()
|
Updater()
|
||||||
// 2. start
|
// 2. start
|
||||||
exec.Command("./nekoray").Start()
|
exec.Command("./Throne").Start()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,17 +16,17 @@ func Updater() {
|
|||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
os.RemoveAll("./usr")
|
os.RemoveAll("./usr")
|
||||||
}
|
}
|
||||||
os.RemoveAll("./nekoray_update")
|
os.RemoveAll("./Throne_update")
|
||||||
}
|
}
|
||||||
|
|
||||||
// find update package
|
// find update package
|
||||||
var updatePackagePath string
|
var updatePackagePath string
|
||||||
if len(os.Args) == 2 && Exist(os.Args[1]) {
|
if len(os.Args) == 2 && Exist(os.Args[1]) {
|
||||||
updatePackagePath = os.Args[1]
|
updatePackagePath = os.Args[1]
|
||||||
} else if Exist("./nekoray.zip") {
|
} else if Exist("./Throne.zip") {
|
||||||
updatePackagePath = "./nekoray.zip"
|
updatePackagePath = "./Throne.zip"
|
||||||
} else if Exist("./nekoray.tar.gz") {
|
} else if Exist("./Throne.tar.gz") {
|
||||||
updatePackagePath = "./nekoray.tar.gz"
|
updatePackagePath = "./Throne.tar.gz"
|
||||||
} else {
|
} else {
|
||||||
log.Fatalln("no update")
|
log.Fatalln("no update")
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ func Updater() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err.Error())
|
log.Fatalln(err.Error())
|
||||||
}
|
}
|
||||||
err = extract.Zip(context.Background(), f, dir+string(os.PathSeparator)+"nekoray_update", nil)
|
err = extract.Zip(context.Background(), f, dir+string(os.PathSeparator)+"Throne_update", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err.Error())
|
log.Fatalln(err.Error())
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ func Updater() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err.Error())
|
log.Fatalln(err.Error())
|
||||||
}
|
}
|
||||||
err = extract.Gz(context.Background(), f, dir+string(os.PathSeparator)+"nekoray_update", nil)
|
err = extract.Gz(context.Background(), f, dir+string(os.PathSeparator)+"Throne_update", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err.Error())
|
log.Fatalln(err.Error())
|
||||||
}
|
}
|
||||||
@ -66,15 +66,15 @@ func Updater() {
|
|||||||
removeAll("./*.dmp")
|
removeAll("./*.dmp")
|
||||||
|
|
||||||
// update move
|
// update move
|
||||||
err = Mv("./nekoray_update/nekoray", "./")
|
err = Mv("./Throne_update/Throne", "./")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
MessageBoxPlain("NekoGui Updater", "Update failed. Please close the running instance and run the updater again.\n\n"+err.Error())
|
MessageBoxPlain("Throne Updater", "Update failed. Please close the running instance and run the updater again.\n\n"+err.Error())
|
||||||
log.Fatalln(err.Error())
|
log.Fatalln(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
os.RemoveAll("./nekoray_update")
|
os.RemoveAll("./Throne_update")
|
||||||
os.RemoveAll("./nekoray.zip")
|
os.RemoveAll("./Throne.zip")
|
||||||
os.RemoveAll("./nekoray.tar.gz")
|
os.RemoveAll("./Throne.tar.gz")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Exist(path string) bool {
|
func Exist(path string) bool {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user