new: add tunnel service
This commit is contained in:
15
custom/command_admin_service.go
Normal file
15
custom/command_admin_service.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2015 Daniel Theophanes.
|
||||
// Use of this source code is governed by a zlib-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// simple does nothing except block while running the service.
|
||||
package main
|
||||
|
||||
import "C"
|
||||
import "github.com/hiddify/libcore/admin_service"
|
||||
|
||||
//export AdminServiceStart
|
||||
func AdminServiceStart(arg *C.char) {
|
||||
goArg := C.GoString(arg)
|
||||
admin_service.StartService(goArg)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func parse(path *C.char, tempPath *C.char, debug bool) (CErr *C.char) {
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
err = os.WriteFile(C.GoString(path), config, 0777)
|
||||
err = os.WriteFile(C.GoString(path), config, 0644)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import "C"
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/hiddify/libcore/bridge"
|
||||
)
|
||||
@@ -26,7 +27,7 @@ func propagateStatus(newStatus string) {
|
||||
func stopAndAlert(alert string, err error) error {
|
||||
status = Stopped
|
||||
message := err.Error()
|
||||
|
||||
fmt.Printf("Error: %s: %v\n", alert, err)
|
||||
msg, _ := json.Marshal(StatusMessage{Status: status, Alert: &alert, Message: &message})
|
||||
bridge.SendStringToPort(statusPropagationPort, string(msg))
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user