-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from shanghaobo/dev
增加socket转发功能
- Loading branch information
Showing
11 changed files
with
208 additions
and
17 deletions.
There are no files selected for viewing
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,3 +1,4 @@ | ||
.idea/ | ||
http-win-notice.exe | ||
http-win-notice.exe~ | ||
http-win-notice.exe~ | ||
dist/ |
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,3 +1,13 @@ | ||
windres -o resources.syso build/res.rc | ||
go build -o http-win-notice.exe -ldflags="-extldflags -static -H windowsgui -s -w" | ||
del resources.syso | ||
go env -w CGO_ENABLED=1 GOOS=windows GOARCH=amd64 | ||
go build -o dist/http-win-notice.exe -ldflags="-extldflags -static -H windowsgui -s -w" | ||
del resources.syso | ||
|
||
go env -w CGO_ENABLED=0 GOOS=linux GOARCH=amd64 | ||
cd forward/server | ||
go build -o "../../dist/forward/forward-server" | ||
|
||
go env -w CGO_ENABLED=0 GOOS=windows GOARCH=amd64 | ||
go build -o "../../dist/forward/forward-server.exe" | ||
|
||
go env -w CGO_ENABLED=1 |
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,17 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/shanghaobo/go-http-forward/client" | ||
"http-win-notice/utils/setting" | ||
"strconv" | ||
) | ||
|
||
func StartClient() { | ||
if setting.Config.Forward.Enable != 1 { | ||
return | ||
} | ||
go func() { | ||
forward := setting.Config.Forward | ||
client.Start(forward.ServerAddr, strconv.Itoa(forward.ServerPort), forward.Token, "http://127.0.0.1:"+strconv.Itoa(setting.Config.Port)+"/api/toast") | ||
}() | ||
} |
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,8 @@ | ||
package main | ||
|
||
type ConfigType struct { | ||
ServerPort int `yaml:"server_port"` | ||
Token string `yaml:"token"` | ||
ApiToken string `yaml:"api_token"` | ||
ApiPort int `yaml:"api_port"` | ||
} |
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,4 @@ | ||
server_port: 9919 | ||
token: httpwinnotice123456 | ||
api_port: 19009 | ||
api_token: httpforward123456 |
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,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/shanghaobo/go-http-forward/server" | ||
"gopkg.in/yaml.v3" | ||
"log" | ||
"os" | ||
"path" | ||
"path/filepath" | ||
"strconv" | ||
) | ||
|
||
var Config ConfigType | ||
|
||
func init() { | ||
Config = ConfigType{} | ||
exePath, _ := os.Executable() | ||
configPath := path.Join(filepath.Dir(exePath), "config.yml") | ||
dataBytes, err := os.ReadFile(configPath) | ||
if err != nil { | ||
log.Fatalln("读取配置文件失败") | ||
} | ||
fmt.Println("yaml 文件的内容: \n", string(dataBytes)) | ||
|
||
err = yaml.Unmarshal(dataBytes, &Config) | ||
if err != nil { | ||
fmt.Println("解析config失败") | ||
log.Fatalln("解析config失败") | ||
} | ||
} | ||
|
||
func main() { | ||
server.Start(strconv.Itoa(Config.ServerPort), Config.Token, Config.ApiToken, strconv.Itoa(Config.ApiPort)) | ||
} |
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
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