Compare commits
20
Commits
87509ff803
..
v0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ef9cc3a51 | ||
|
|
3e0ad381aa | ||
|
|
bd1e6dd113 | ||
|
|
622e3cdb87 | ||
|
|
11d830e3a7 | ||
|
|
16a5f22448 | ||
|
|
9707a60934 | ||
|
|
3cf21ba510 | ||
|
|
cd5ff317dc | ||
|
|
e85f491d99 | ||
|
|
eebcbde94d | ||
|
|
f0bf55ca41 | ||
|
|
1d536d433e | ||
|
|
cc9d51cf2b | ||
|
|
22a9df93ea | ||
|
|
ff1c2e4554 | ||
|
|
a254f42d92 | ||
|
|
c6bee2e4a7 | ||
|
|
72983f8adc | ||
|
|
f01aafe454 |
+3
-1
@@ -1,8 +1,10 @@
|
||||
FROM golang:1.16
|
||||
FROM golang:1.16-alpine
|
||||
|
||||
WORKDIR /go/src/gidbig
|
||||
COPY . .
|
||||
RUN go get -d -v .
|
||||
RUN go install -v .
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD [ "gidbig" ]
|
||||
@@ -0,0 +1,7 @@
|
||||
.PHONY: build
|
||||
build:
|
||||
go build -o ./gidbig ./main.go ./webserver.go
|
||||
clean:
|
||||
rm -f ./gidbig
|
||||
install:
|
||||
go install dev.ixab.de/da/gidbig
|
||||
@@ -22,4 +22,4 @@ Coming soon.
|
||||
## Known issues
|
||||
- `https://discordapp.com/api/oauth2` needs to be added to `brokenAuthHeaderProviders` in `golang.org/x/oauth2/internal/token.go` in order for oauth2 to work again.
|
||||
|
||||
Please use the issue tracker.
|
||||
Please use the issue tracker. Thank you!
|
||||
|
||||
+2
-2
@@ -3,6 +3,6 @@ shard: ""
|
||||
shardcount: ""
|
||||
owner: ""
|
||||
port: 8080
|
||||
redirecturl: "https://yourbot"
|
||||
ci: 1337
|
||||
redirecturl: "https://bot.example.org:1337"
|
||||
ci: 0
|
||||
cs: ""
|
||||
@@ -1,13 +1,25 @@
|
||||
module dev.ixab.de/da/gidbig
|
||||
|
||||
go 1.16
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.23.1
|
||||
github.com/bwmarrin/discordgo v0.23.2
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gorilla/sessions v1.2.1
|
||||
github.com/simplesurance/go-ip-anonymizer v0.0.0-20200429124537-35a880f8e87d
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/gorilla/securecookie v1.1.1 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
|
||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d // indirect
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
)
|
||||
|
||||
@@ -33,8 +33,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/bwmarrin/discordgo v0.23.1 h1:xlK4/69bpl/VSoCYaKe3BOc9j1HkNopoRdCppRYu8dk=
|
||||
github.com/bwmarrin/discordgo v0.23.1/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
|
||||
github.com/bwmarrin/discordgo v0.23.2 h1:BzrtTktixGHIu9Tt7dEE6diysEF9HWnXeHuoJEt2fH4=
|
||||
github.com/bwmarrin/discordgo v0.23.2/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
@@ -78,6 +78,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
@@ -88,6 +91,7 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
@@ -108,6 +112,8 @@ github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7Fsg
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
@@ -123,6 +129,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/simplesurance/go-ip-anonymizer v0.0.0-20200429124537-35a880f8e87d h1:4FkGkGts6gLznca6fgclIvbupwbq543mb/fFkog4VIg=
|
||||
github.com/simplesurance/go-ip-anonymizer v0.0.0-20200429124537-35a880f8e87d/go.mod h1:fTTj1EOmRdtuwYw3jF/1X2dTa0N1BdbZhrpA21N/S4I=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -144,6 +152,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -201,6 +211,8 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d h1:62NvYBuaanGXR2ZOfwDFkhhl6X1DUgf8qg3GuQvxZsE=
|
||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -208,6 +220,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 h1:0Ja1LBD+yisY6RWM/BH7TJVXWsSjs2VwBSmvSX4HdBc=
|
||||
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg=
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -243,6 +257,8 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 h1:B6caxRw+hozq68X2MY7jEpZh/cr4/aHLv9xU8Kkadrw=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -319,6 +335,8 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
@@ -371,12 +389,18 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
||||
@@ -418,6 +418,7 @@ func displayBotStats(cid string) {
|
||||
discord.ChannelMessageSend(cid, buf.String())
|
||||
}
|
||||
|
||||
// what did I start here?
|
||||
func utilGetMentioned(s *discordgo.Session, m *discordgo.MessageCreate) *discordgo.User {
|
||||
for _, mention := range m.Mentions {
|
||||
if mention.ID != s.State.Ready.User.ID {
|
||||
@@ -436,7 +437,7 @@ func handleBotControlMessages(s *discordgo.Session, m *discordgo.MessageCreate,
|
||||
}
|
||||
}
|
||||
|
||||
func setIdleStatus(s *discordgo.Session) {
|
||||
func setIdleStatus() {
|
||||
games := []string{
|
||||
"Terranigma",
|
||||
"Secret of Mana",
|
||||
@@ -476,8 +477,8 @@ func setIdleStatus(s *discordgo.Session) {
|
||||
"R-Type",
|
||||
}
|
||||
for {
|
||||
s.UpdateStreamingStatus(1, "", "")
|
||||
s.UpdateGameStatus(0, games[randomRange(0, len(games))])
|
||||
discord.UpdateStreamingStatus(1, "", "")
|
||||
discord.UpdateGameStatus(0, games[randomRange(0, len(games))])
|
||||
time.Sleep(time.Duration(randomRange(5, 15)) * time.Minute)
|
||||
}
|
||||
}
|
||||
@@ -639,6 +640,9 @@ func loadConfigFile() *config {
|
||||
|
||||
func main() {
|
||||
config := loadConfigFile()
|
||||
var (
|
||||
err error
|
||||
)
|
||||
|
||||
// create SoundCollections by scanning the audio folder
|
||||
createCollections()
|
||||
@@ -663,7 +667,7 @@ func main() {
|
||||
|
||||
// Create a discord session
|
||||
log.Info("Starting discord session...")
|
||||
discord, err := discordgo.New("Bot " + config.Token)
|
||||
discord, err = discordgo.New("Bot " + config.Token)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"error": err,
|
||||
@@ -690,7 +694,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
go setIdleStatus(discord)
|
||||
go setIdleStatus()
|
||||
// We're running!
|
||||
log.Info("Gidbig is ready. Quit with CTRL-C.")
|
||||
|
||||
|
||||
+63
-8
@@ -4,15 +4,20 @@ import (
|
||||
"bufio"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/simplesurance/go-ip-anonymizer/ipanonymizer"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
@@ -37,8 +42,14 @@ var (
|
||||
TokenURL: "https://discordapp.com/api/oauth2/token",
|
||||
}
|
||||
tmpls = map[string]*template.Template{}
|
||||
|
||||
// TODO change secret
|
||||
store *sessions.CookieStore
|
||||
|
||||
ipAnonymizer = ipanonymizer.NewWithMask(
|
||||
net.CIDRMask(16, 32),
|
||||
net.CIDRMask(64, 128),
|
||||
)
|
||||
)
|
||||
|
||||
// SoundItem is used to represent a sound of our COLLECTIONS for html generation
|
||||
@@ -67,8 +78,8 @@ func startWebServer(port string, ci string, cs string, redirectURL string) {
|
||||
r := mux.NewRouter()
|
||||
r.HandleFunc("/", handleMain)
|
||||
r.HandleFunc("/logout", handleLogout)
|
||||
r.HandleFunc("/discordLogin", handlediscordLogin)
|
||||
r.HandleFunc("/discordCallback", handlediscordCallback)
|
||||
r.HandleFunc("/discordLogin", handleDiscordLogin)
|
||||
r.HandleFunc("/discordCallback", handleDiscordCallback)
|
||||
r.HandleFunc("/playsound", handlePlaySound)
|
||||
http.Handle("/", r)
|
||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
|
||||
@@ -76,6 +87,7 @@ func startWebServer(port string, ci string, cs string, redirectURL string) {
|
||||
}
|
||||
|
||||
func handlePlaySound(w http.ResponseWriter, r *http.Request) {
|
||||
log.Infoln("WebUI /playsound Request from " + r.RemoteAddr)
|
||||
r.ParseForm()
|
||||
sound, soundCollection := findSoundAndCollection(r.FormValue("command"), r.FormValue("soundname"))
|
||||
session, _ := store.Get(r, "gidbig-session")
|
||||
@@ -106,13 +118,13 @@ func handlePlaySound(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func handleMain(w http.ResponseWriter, r *http.Request) {
|
||||
logWebRequests(r)
|
||||
session, _ := store.Get(r, "gidbig-session")
|
||||
if session.Values["discordUsername"] != nil {
|
||||
var prefixes []string
|
||||
var si []SoundItem
|
||||
for _, sc := range COLLECTIONS {
|
||||
var newSoundItemRandom SoundItem
|
||||
newSoundItemRandom = SoundItem{
|
||||
newSoundItemRandom := SoundItem{
|
||||
Itemprefix: sc.Prefix,
|
||||
Itemcommand: "!" + sc.Prefix,
|
||||
Itemsoundname: "",
|
||||
@@ -122,8 +134,7 @@ func handleMain(w http.ResponseWriter, r *http.Request) {
|
||||
prefixes = append(prefixes, sc.Prefix)
|
||||
si = append(si, newSoundItemRandom)
|
||||
for _, snd := range sc.Sounds {
|
||||
var newSoundItem SoundItem
|
||||
newSoundItem = SoundItem{
|
||||
newSoundItem := SoundItem{
|
||||
Itemprefix: sc.Prefix,
|
||||
Itemcommand: "!" + sc.Prefix,
|
||||
Itemsoundname: snd.Name,
|
||||
@@ -208,6 +219,7 @@ func handleMain(w http.ResponseWriter, r *http.Request) {
|
||||
tmpls["home.html"].ExecuteTemplate(w, "footer", map[string]interface{}{})
|
||||
}
|
||||
func handleLogout(w http.ResponseWriter, r *http.Request) {
|
||||
log.Infoln("WebUI /logout Request from " + r.RemoteAddr)
|
||||
cookie := &http.Cookie{
|
||||
Name: "gidbig-session",
|
||||
Value: "",
|
||||
@@ -217,7 +229,8 @@ func handleLogout(w http.ResponseWriter, r *http.Request) {
|
||||
http.SetCookie(w, cookie)
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
}
|
||||
func handlediscordLogin(w http.ResponseWriter, r *http.Request) {
|
||||
func handleDiscordLogin(w http.ResponseWriter, r *http.Request) {
|
||||
logWebRequests(r)
|
||||
b := make([]byte, 16)
|
||||
rand.Read(b)
|
||||
oauthStateString = base64.URLEncoding.EncodeToString(b)
|
||||
@@ -230,7 +243,8 @@ func handlediscordLogin(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, url, http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
func handlediscordCallback(w http.ResponseWriter, r *http.Request) {
|
||||
func handleDiscordCallback(w http.ResponseWriter, r *http.Request) {
|
||||
logWebRequests(r)
|
||||
session, err := store.Get(r, "gidbig-session")
|
||||
if err != nil {
|
||||
fmt.Fprintln(w, "aborted")
|
||||
@@ -275,3 +289,44 @@ func handlediscordCallback(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
func parseIPPort(s string) (ip net.IP, port, space string, err error) {
|
||||
ip = net.ParseIP(s)
|
||||
if ip == nil {
|
||||
var host string
|
||||
host, port, err = net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if port != "" {
|
||||
// This check only makes sense if service names are not allowed
|
||||
if _, err = strconv.ParseUint(port, 10, 16); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
ip = net.ParseIP(host)
|
||||
}
|
||||
if ip == nil {
|
||||
err = errors.New("invalid address format")
|
||||
} else {
|
||||
space = "IPv6"
|
||||
if ip4 := ip.To4(); ip4 != nil {
|
||||
space = "IPv4"
|
||||
ip = ip4
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func logWebRequests(r *http.Request) {
|
||||
ip, port, _, err := parseIPPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
log.Warnln("Error parsing IP address for WebUI Request to " + r.RequestURI)
|
||||
}
|
||||
anonIP, err := ipAnonymizer.IPString(ip.String())
|
||||
if err != nil {
|
||||
log.Warnln("Could not anonymize IP address for WebUI Request to " + r.RequestURI)
|
||||
} else {
|
||||
log.Infoln("WebUI Request to " + r.RequestURI + " from " + anonIP + port)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user