mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30: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
|
||||
*.exe
|
||||
*.dat
|
||||
/cmd/nekoray_core/nekoray_core
|
||||
/cmd/nekobox_core/nekobox_core
|
||||
*.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) {
|
||||
if d == nil {
|
||||
log.Println("No DnsManager, you may need to restart nekoray")
|
||||
log.Println("No DnsManager, you may need to restart Throne")
|
||||
return
|
||||
}
|
||||
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) {
|
||||
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
|
||||
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) {
|
||||
if d == nil {
|
||||
log.Println("No DnsManager, you may need to restart nekoray")
|
||||
return false, E.New("No Dns Manager, 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 Throne")
|
||||
}
|
||||
|
||||
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 {
|
||||
if d == nil {
|
||||
log.Println("No DnsManager, you may need to restart nekoray")
|
||||
return E.New("No dns Manager, 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 Throne")
|
||||
}
|
||||
|
||||
if ifc == nil {
|
||||
|
||||
@ -45,7 +45,7 @@ type DnsManager struct {
|
||||
|
||||
func (d *DnsManager) HandleUnderlyingDNS(ifc *control.Interface, flag int) {
|
||||
if d == nil {
|
||||
log.Println("No DnsManager, you may need to restart nekoray")
|
||||
log.Println("No DnsManager, you may need to restart Throne")
|
||||
return
|
||||
}
|
||||
if ifc == nil {
|
||||
|
||||
@ -30,9 +30,9 @@ func main() {
|
||||
time.Sleep(time.Second)
|
||||
Updater()
|
||||
// 3. start
|
||||
exec.Command("./nekoray.exe").Start()
|
||||
exec.Command("./Throne.exe").Start()
|
||||
} else {
|
||||
// 1. nekoray stop itself and run "updater.exe"
|
||||
// 1. Throne stop itself and run "updater.exe"
|
||||
Copy("./updater.exe", "./updater.old")
|
||||
exec.Command("./updater.old", os.Args[1:]...).Start()
|
||||
}
|
||||
@ -40,7 +40,7 @@ func main() {
|
||||
// 1. update files
|
||||
Updater()
|
||||
// 2. start
|
||||
exec.Command("./nekoray").Start()
|
||||
exec.Command("./Throne").Start()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -16,17 +16,17 @@ func Updater() {
|
||||
if runtime.GOOS == "linux" {
|
||||
os.RemoveAll("./usr")
|
||||
}
|
||||
os.RemoveAll("./nekoray_update")
|
||||
os.RemoveAll("./Throne_update")
|
||||
}
|
||||
|
||||
// find update package
|
||||
var updatePackagePath string
|
||||
if len(os.Args) == 2 && Exist(os.Args[1]) {
|
||||
updatePackagePath = os.Args[1]
|
||||
} else if Exist("./nekoray.zip") {
|
||||
updatePackagePath = "./nekoray.zip"
|
||||
} else if Exist("./nekoray.tar.gz") {
|
||||
updatePackagePath = "./nekoray.tar.gz"
|
||||
} else if Exist("./Throne.zip") {
|
||||
updatePackagePath = "./Throne.zip"
|
||||
} else if Exist("./Throne.tar.gz") {
|
||||
updatePackagePath = "./Throne.tar.gz"
|
||||
} else {
|
||||
log.Fatalln("no update")
|
||||
}
|
||||
@ -43,7 +43,7 @@ func Updater() {
|
||||
if err != nil {
|
||||
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 {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
@ -54,7 +54,7 @@ func Updater() {
|
||||
if err != nil {
|
||||
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 {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
@ -66,15 +66,15 @@ func Updater() {
|
||||
removeAll("./*.dmp")
|
||||
|
||||
// update move
|
||||
err = Mv("./nekoray_update/nekoray", "./")
|
||||
err = Mv("./Throne_update/Throne", "./")
|
||||
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())
|
||||
}
|
||||
|
||||
os.RemoveAll("./nekoray_update")
|
||||
os.RemoveAll("./nekoray.zip")
|
||||
os.RemoveAll("./nekoray.tar.gz")
|
||||
os.RemoveAll("./Throne_update")
|
||||
os.RemoveAll("./Throne.zip")
|
||||
os.RemoveAll("./Throne.tar.gz")
|
||||
}
|
||||
|
||||
func Exist(path string) bool {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user