add basic sign-ping logic
This commit is contained in:
parent
add60a1421
commit
be45209509
5 changed files with 94 additions and 0 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
|
||||
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.
|
3
addr.go
Normal file
3
addr.go
Normal file
|
@ -0,0 +1,3 @@
|
|||
package mention
|
||||
|
||||
type Addr string
|
13
go.mod
13
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
|
||||
)
|
||||
|
|
14
go.sum
Normal file
14
go.sum
Normal file
|
@ -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=
|
43
ping.go
43
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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue