Skip to content

Commit

Permalink
chore: update workflow, makefile and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yuweizzz committed Oct 30, 2022
1 parent d7b49ce commit 89e60d5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 36 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
- name: Build MacOS app
if: matrix.os == 'macos-latest'
run: |
GOARCH="amd64" GOOS="darwin" make build
cp nginx_conf.tpl build/nginx_conf.tpl
make mac
- name: Upload MacOS artifact
if: matrix.os == 'macos-latest'
Expand All @@ -37,9 +36,7 @@ jobs:
- name: Build linux app
if: matrix.os == 'ubuntu-latest'
run: |
GOARCH="amd64" GOOS="linux" make build
cp nginx_conf.tpl build/nginx_conf.tpl
cp scripts/linux/* build/
make linux
- name: Upload linux artifact
if: matrix.os == 'ubuntu-latest'
Expand All @@ -51,11 +48,7 @@ jobs:
- name: Build Windows app
if: matrix.os == 'ubuntu-latest'
run: |
make clean
GOARCH="amd64" GOOS="windows" make build
mv build/sidecar-server build/sidecar-server.exe
cp nginx_conf.tpl build/nginx_conf.tpl
cp scripts/windows/* build/
make windows
- name: Upload Windows artifact
if: matrix.os == 'ubuntu-latest'
Expand Down
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,25 @@ GOFILE := $(shell find . -name "*.go" | xargs)
lint:
gofmt -w $(GOFILE)

.PHONY: build
build:
go build -o $(OUTPUTDIR)/$(SIDECAR_SERVER) $(SIDECAR_SERVER_DIR)/$(MAIN)
.PHONY: linux windows mac
linux: clean build_linux copy_tpl copy_linux_scripts
windows: clean build_windows copy_tpl copy_windows_scripts
mac: clean build_mac copy_tpl

.PHONY: build_linux build_windows build_mac copy_tpl
build_linux:
GOARCH="amd64" GOOS="linux" go build -o $(OUTPUTDIR)/$(SIDECAR_SERVER) $(SIDECAR_SERVER_DIR)/$(MAIN)
build_windows:
GOARCH="amd64" GOOS="windows" go build -ldflags="-H windowsgui" -o $(OUTPUTDIR)/sidecar-server.exe $(SIDECAR_SERVER_DIR)/$(MAIN)
build_mac:
GOARCH="amd64" GOOS="darwin" go build -o $(OUTPUTDIR)/$(SIDECAR_SERVER) $(SIDECAR_SERVER_DIR)/$(MAIN)
copy_tpl:
cp nginx_conf.tpl $(OUTPUTDIR)/nginx_conf.tpl
cp conf_toml.tpl $(OUTPUTDIR)/conf.toml
copy_linux_scripts:
cp scripts/linux/* $(OUTPUTDIR)/
copy_windows_scripts:
cp scripts/windows/* $(OUTPUTDIR)/

.PHONY: clean
clean:
Expand Down
22 changes: 22 additions & 0 deletions conf_toml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[Sidecar]
ProxyPort = 4396
OnlyListenIPv4 = true
LogLevel = "info"

[RemoteProxy]
Server = "remote.server.com" # 需要替换为实际的远端服务域名
ComplexPath = "FreeFreeFree" # 需要替换为实际的远端服务入口路径
GfwListUrl = "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt"

[RemoteProxy.CustomHeaders]
# 需要替换为实际的远端服务允许通过的 Header
AuthHeader = "Secret"

# 这部分信息可以生成远端服务的 nginx.conf ,仅在 create-nginx-conf 时被使用
[RemoteProxyConf]
EnableListenHTTP2 = true
EnableWebSocketProxy = true
EnableModernTLSOnly = true
NginxWorkDir = "/usr/local/openresty/nginx/logs"
SSLCertificatePath = "/usr/local/openresty/nginx/conf/proxy/proxy.crt"
SSLPrivateKeyPath = "/usr/local/openresty/nginx/conf/proxy/proxy.pri"
14 changes: 7 additions & 7 deletions scripts/windows/start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
set PROXYSERVER=127.0.0.1:4396
set PROXYOVERRIDE=localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*

echo "set Proxy Server ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d %PROXYSERVER% /f
echo set Proxy Server ......
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d %PROXYSERVER% /f > NUL

echo "set Proxy Override ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d %PROXYOVERRIDE% /f
echo set Proxy Override ......
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d %PROXYOVERRIDE% /f > NUL

echo "Enable Proxy Server ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
echo Enable Proxy Server ......
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f > NUL

echo "Start Sidecar Server ......"
echo Start Sidecar Server ......
%cd%/sidecar-server.exe start
14 changes: 4 additions & 10 deletions scripts/windows/start_daemon.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
set PROXYSERVER=127.0.0.1:4396
set PROXYOVERRIDE=localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*

echo "Start Sidecar Server ......"
%cd%/sidecar-server.exe start -daemon
cmd /c start %cd%/sidecar-server.exe start -daemon

echo "set Proxy Server ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d %PROXYSERVER% /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d %PROXYSERVER% /f > NUL

echo "set Proxy Override ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d %PROXYOVERRIDE% /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d %PROXYOVERRIDE% /f > NUL

echo "Enable Proxy Server ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f > NUL

echo "Press Any Key To Close This Window ......"
pause
exit
8 changes: 2 additions & 6 deletions scripts/windows/stop_daemon.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
@echo off

echo "Disable Proxy Server ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f > NUL

echo "Stop Sidecar Server ......"
%cd%/sidecar-server.exe stop
cmd /c %cd%/sidecar-server.exe stop

echo "Press Any Key To Close This Window ......"
pause
exit

0 comments on commit 89e60d5

Please sign in to comment.