44 lines
922 B
Go
44 lines
922 B
Go
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
|
|
}
|