doc: add info for customize building

This commit is contained in:
nadoo 2020-10-02 00:03:49 +08:00
parent edfca215c5
commit bc68535dcd
2 changed files with 27 additions and 15 deletions

View File

@ -71,15 +71,9 @@ we can set up local listeners as proxy servers, and forward requests to internet
## Install ## Install
Binary Download: Download:
- [https://github.com/nadoo/glider/releases](https://github.com/nadoo/glider/releases) - [https://github.com/nadoo/glider/releases](https://github.com/nadoo/glider/releases)
Build from source code (requires **Go 1.15+** ):
```bash
git clone https://github.com/nadoo/glider
cd glider && go build
```
ArchLinux: ArchLinux:
```bash ```bash
sudo pacman -S glider sudo pacman -S glider
@ -371,9 +365,7 @@ glider -config CONFIGPATH -listen :8080 -verbose
## Service ## Service
#### Scheme: **Scheme:** ```service=SERVICE_NAME[,SERVICE_CONFIG]```
```service=SERVICE_NAME[,SERVICE_CONFIG]```
- dhcpd: - dhcpd:
- service=dhcpd,INTERFACE,START_IP,END_IP - service=dhcpd,INTERFACE,START_IP,END_IP
@ -383,6 +375,26 @@ glider -config CONFIGPATH -listen :8080 -verbose
- systemd: [https://github.com/nadoo/glider/blob/master/systemd/](https://github.com/nadoo/glider/blob/master/systemd/) - systemd: [https://github.com/nadoo/glider/blob/master/systemd/](https://github.com/nadoo/glider/blob/master/systemd/)
## Customize Build
You can customize and build glider by yourself if you want a smaller binary.
1. Clone the source code:
```bash
git clone https://github.com/nadoo/glider
```
2. Customize features:
```open `feature.go` & `feature_linux.go`, comment out the packages you don't need```
```bash
// _ "github.com/nadoo/glider/proxy/kcp"
```
3. Build it(requires **Go 1.15+** )
```bash
cd glider && go build
```
## Links ## Links
- [ipset](https://github.com/nadoo/ipset): netlink ipset package for Go. - [ipset](https://github.com/nadoo/ipset): netlink ipset package for Go.

View File

@ -17,7 +17,7 @@ type TLS struct {
proxy proxy.Proxy proxy proxy.Proxy
addr string addr string
tlsConfig *stdtls.Config config *stdtls.Config
serverName string serverName string
skipVerify bool skipVerify bool
@ -83,7 +83,7 @@ func NewTLSDialer(s string, d proxy.Dialer) (proxy.Dialer, error) {
return nil, err return nil, err
} }
p.tlsConfig = &stdtls.Config{ p.config = &stdtls.Config{
ServerName: p.serverName, ServerName: p.serverName,
InsecureSkipVerify: p.skipVerify, InsecureSkipVerify: p.skipVerify,
ClientSessionCache: stdtls.NewLRUClientSessionCache(64), ClientSessionCache: stdtls.NewLRUClientSessionCache(64),
@ -114,7 +114,7 @@ func NewTLSServer(s string, p proxy.Proxy) (proxy.Server, error) {
return nil, err return nil, err
} }
t.tlsConfig = &stdtls.Config{ t.config = &stdtls.Config{
Certificates: []stdtls.Certificate{cert}, Certificates: []stdtls.Certificate{cert},
MinVersion: stdtls.VersionTLS12, MinVersion: stdtls.VersionTLS12,
} }
@ -155,7 +155,7 @@ func (s *TLS) Serve(c net.Conn) {
// defer c.Close() // defer c.Close()
if s.server != nil { if s.server != nil {
cc := stdtls.Server(c, s.tlsConfig) cc := stdtls.Server(c, s.config)
s.server.Serve(cc) s.server.Serve(cc)
} }
} }
@ -176,7 +176,7 @@ func (s *TLS) Dial(network, addr string) (net.Conn, error) {
return nil, err return nil, err
} }
c := stdtls.Client(cc, s.tlsConfig) c := stdtls.Client(cc, s.config)
err = c.Handshake() err = c.Handshake()
return c, err return c, err
} }