From be452095090dd4c2eb9e17b0ba5e2a9921265e86 Mon Sep 17 00:00:00 2001 From: risotto Date: Mon, 7 Apr 2025 04:09:12 -0600 Subject: [PATCH] add basic sign-ping logic --- LICENSE | 21 +++++++++++++++++++++ addr.go | 3 +++ go.mod | 13 +++++++++++++ go.sum | 14 ++++++++++++++ ping.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 LICENSE create mode 100644 addr.go create mode 100644 go.sum diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2fdc5c2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright © 2024 NAME HERE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/addr.go b/addr.go new file mode 100644 index 0000000..f338747 --- /dev/null +++ b/addr.go @@ -0,0 +1,3 @@ +package mention + +type Addr string diff --git a/go.mod b/go.mod index 58a9a87..dacef72 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,16 @@ module git.bivouac.wiki/go/mention go 1.22.5 + +require ( + git.bivouac.wiki/go/bloat v0.0.0-20250407094740-2ee034250e69 + git.bivouac.wiki/go/phish v0.0.0-20250407100600-4994fb139ea6 + golang.org/x/net v0.21.0 +) + +require ( + aead.dev/minisign v0.3.0 // indirect + filippo.io/age v1.2.1 // indirect + golang.org/x/crypto v0.24.0 // indirect + golang.org/x/sys v0.21.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..f4d1de7 --- /dev/null +++ b/go.sum @@ -0,0 +1,14 @@ +aead.dev/minisign v0.3.0 h1:8Xafzy5PEVZqYDNP60yJHARlW1eOQtsKNp/Ph2c0vRA= +aead.dev/minisign v0.3.0/go.mod h1:NLvG3Uoq3skkRMDuc3YHpWUTMTrSExqm+Ij73W13F6Y= +filippo.io/age v1.2.1 h1:X0TZjehAZylOIj4DubWYU1vWQxv9bJpo+Uu2/LGhi1o= +filippo.io/age v1.2.1/go.mod h1:JL9ew2lTN+Pyft4RiNGguFfOpewKwSHm5ayKD/A4004= +git.bivouac.wiki/go/bloat v0.0.0-20250407094740-2ee034250e69 h1:QRR3RiX6e42Tk0zD5o6OZ/Smic8ULOjO21xRtzcneKs= +git.bivouac.wiki/go/bloat v0.0.0-20250407094740-2ee034250e69/go.mod h1:eENxh70rdl9L8YurQY1wpaW7zRh9KUgSYN7bSbVAssE= +git.bivouac.wiki/go/phish v0.0.0-20250407100600-4994fb139ea6 h1:dwvi5dyEg56naUrT82dWcxNXrD4KI/Eyp+WBA9LD+t8= +git.bivouac.wiki/go/phish v0.0.0-20250407100600-4994fb139ea6/go.mod h1:frn1dDLluD6IBycpRpRWBXthNCvi/x4Bzck9AZkeu2Y= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/ping.go b/ping.go index 5027eff..7ad4b4a 100644 --- a/ping.go +++ b/ping.go @@ -1 +1,44 @@ package mention + +import ( + "encoding/base64" + "fmt" + "net/http" + + "git.bivouac.wiki/go/phish" + "golang.org/x/net/proxy" +) + +func SignedPing(greeting string, a Addr, other phish.Identity, self phish.Identity) error { + type HelloMention struct { + Greeting string + Addr Addr + } + // pick one of the carriers as the addr + hi := HelloMention{ + Greeting: greeting, + Addr: Addr(self.Carrier[0]), + } + hello, err := self.SignMsgFor(hi, other) + if err != nil { + return err + } + dialer, err := proxy.SOCKS5("tcp", "127.0.0.1:9050", nil, nil) + if err != nil { + fmt.Printf(err) + return err + } + conn, err := dialer.Dial("tcp", a) + if err != nil { + fmt.Printf(err) + return err + } + defer conn.Close() + transport := &http.Transport{ + Dial: conn.Dial, + } + httpClient := http.Client{Transport: transport} + greeturi := base64.URLEncoding.EncodeToString(hello) + httpClient.Get("/bloatphish.xml?hello=" + greeturi) + return nil +}