Skip to content

Commit

Permalink
perf: add LICENSE, docs and runtime scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yuweizzz committed Oct 29, 2022
1 parent 38c9f5b commit d7b49ce
Show file tree
Hide file tree
Showing 11 changed files with 482 additions and 4 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,27 @@ jobs:
if: matrix.os == 'macos-latest'
run: |
GOARCH="amd64" GOOS="darwin" make build
cp nginx_conf.tpl build/nginx_conf.tpl
- name: Upload MacOS artifact
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v3
with:
name: sidecar-release-${{ runner.os }}-amd64
name: sidecar-release-${{ github.ref_name }}-${{ runner.os }}-amd64
path: build/*

- 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/
- name: Upload linux artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: sidecar-release-${{ runner.os }}-amd64
name: sidecar-release-${{ github.ref_name }}-${{ runner.os }}-amd64
path: build/*

- name: Build Windows app
Expand All @@ -51,12 +54,14 @@ jobs:
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/
- name: Upload Windows artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: sidecar-release-Windows-amd64
name: sidecar-release-${{ github.ref_name }}-windows-amd64
path: build/*

release:
Expand Down
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ lint:
.PHONY: build
build:
go build -o $(OUTPUTDIR)/$(SIDECAR_SERVER) $(SIDECAR_SERVER_DIR)/$(MAIN)
cp $(CURDIR)/nginx_conf.tpl $(OUTPUTDIR)/nginx_conf.tpl

.PHONY: clean
clean:
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Introduction

Sidecar is a https proxy server based on MITM.

## Feature

- [x] HTTP proxy
Expand All @@ -9,3 +13,11 @@
- [x] Provide cmd tool
- [ ] Support HTTP2
- [ ] Refactoring

## Get Started

Here is [User Manual](https://github.com/yuweizzz/sidecar/blob/master/docs/zh.md).

## License

[GPL-2.0 license](https://github.com/yuweizzz/sidecar/blob/master/LICENSE)
61 changes: 61 additions & 0 deletions docs/zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Sidecar

基于 MITM 的 Https 代理服务器,用于站点访问加速,是 [dev-sidecar](https://github.com/docmirror/dev-sidecar) 的 golang 实现。

## 使用方法

支持系统包括 Linux , macOS 和 Windows 。

运行服务时需要 `conf.toml` 文件:

``` bash
# conf.toml
[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"
```

修改 `conf.toml` 文件后存放到对应目录,启动服务时会自动生成对应的证书,信任并安装根证书后就可以正常使用。

通过 `sidecar-server start [-conf tomlfile] [-dir workdir] [-daemon]` 启动服务,通过 `sidecar-server stop [-dir workdir]` 停止服务。

不指定 `-conf` 则配置文件必须命名为 `conf.toml` 并且处于当前可执行文件所在的目录;不指定 `-dir` 则默认工作目录为当前可执行文件所在的目录,生成的证书和服务运行时的锁文件都会处于这个目录中;不指定 `-daemon` 则服务会占用当前终端,否则会运行在后台中。

### Windows

在启动服务后,需要手动设置代理服务,或者使用提供的 bat 脚本。

### Linux

在启动服务后,需要声明环境变量:

``` bash
export HTTPS_PROXY=127.0.0.1:4396
```

## 感谢

项目代码参考了以下项目:

- [dev-sidecar](https://github.com/docmirror/dev-sidecar)
- [go-mitmproxy](https://github.com/lqqyt2423/go-mitmproxy)
- [koko](https://github.com/jumpserver/koko)
5 changes: 5 additions & 0 deletions scripts/linux/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

PWD=`pwd`

./sidecar-server start -dir $PWD -conf $PWD/conf.toml
5 changes: 5 additions & 0 deletions scripts/linux/start_daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

PWD=`pwd`

./sidecar-server start -daemon -dir $PWD -conf $PWD/conf.toml
5 changes: 5 additions & 0 deletions scripts/linux/stop_daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

PWD=`pwd`

./sidecar-server stop -dir $PWD
16 changes: 16 additions & 0 deletions scripts/windows/start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off

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 Override ......"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d %PROXYOVERRIDE% /f

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

echo "Start Sidecar Server ......"
%cd%/sidecar-server.exe start
20 changes: 20 additions & 0 deletions scripts/windows/start_daemon.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@echo off

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

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

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

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

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

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

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

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

0 comments on commit d7b49ce

Please sign in to comment.