initial commit
This commit is contained in:
parent
a2a62a0455
commit
0af046784f
|
@ -23,6 +23,11 @@ activate the receiver first:
|
|||
then the sender:
|
||||
`sendafriend send [made-up-name] < file.ext`
|
||||
|
||||
## manage multiple identities
|
||||
|
||||
to have multiple addresses and contact lists, create a directory to hold them and prefix commands like so:
|
||||
env SENDAFRIEND_FOLDER=$HOME/bob sendafriend info
|
||||
|
||||
## <3
|
||||
|
||||
made with love by errorinn
|
40
main.go
40
main.go
|
@ -6,11 +6,11 @@ import (
|
|||
libpeer "cwtch.im/cwtch/peer"
|
||||
"fmt"
|
||||
"github.com/sethvargo/go-diceware/diceware"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/big"
|
||||
"math/big"
|
||||
"os"
|
||||
"time"
|
||||
"path"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
func driftoff() {
|
||||
|
@ -45,16 +45,35 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
log.SetFlags(0)
|
||||
log.SetOutput(ioutil.Discard)
|
||||
//log.SetFlags(0)
|
||||
//log.SetOutput(ioutil.Discard)
|
||||
|
||||
// this is a cwtch server used only to make the "pair" command work
|
||||
// it is completely untrusted and only blinded information is passed through it
|
||||
// it can point to any ol cwtch group, as long as both people running "pair" are using the same one
|
||||
inviteStr := "torv30I0zJgNiUz57gJlxFsp4PUq47WDoKNCL95GEadaLlEE=EsABCiA4MjViZTVjODU0ZDFhNGRhNjM3NmExNTBlYjM2ZjM2NxIgPAl3zAsMfauSZQyiGXlj7u6M6usYN/HqtPD2jafjwTAaOGloZDNlYXdhbjZ2aG1kaDdudDVicXh5aHVlM2k0aXgzb3kyZWZrcHdkaDZyNGptcTNhZXJ0dWlkIkDhF3Ko8nAtEJPvjpCjwFM4py0CeAhYCTc9l9H+Wah8traU15D/JzIHEAKhaDiIzmKqBOECk9Q+G40Y6pXPWKkI"
|
||||
|
||||
peer, err := libpeer.LoadCwtchPeer("Whoami", "be gay do crime")
|
||||
var dirname, filename string
|
||||
if os.Getenv("SENDAFRIEND_FOLDER") != "" {
|
||||
dirname = os.Getenv("SENDAFRIEND_FOLDER")
|
||||
filename = path.Join(dirname, "identity.private")
|
||||
} else {
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
fmt.Printf("\nerror: could not load current user: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
dirname = path.Join(usr.HomeDir, ".sendafriend")
|
||||
filename = path.Join(dirname, "identity.private")
|
||||
}
|
||||
|
||||
os.MkdirAll(dirname, 0700)
|
||||
peer, err := libpeer.LoadCwtchPeer(filename, "be gay do crime")
|
||||
if err != nil {
|
||||
fmt.Println("couldn't load your Whoami file, attempting to create a new one now")
|
||||
fmt.Println("couldn't load your config file, attempting to create a new one now")
|
||||
|
||||
names, err := diceware.Generate(1)
|
||||
peer, err = libpeer.NewCwtchPeer(names[0], "be gay do crime", "Whoami")
|
||||
peer, err = libpeer.NewCwtchPeer(names[0], "be gay do crime", filename)
|
||||
if err != nil {
|
||||
fmt.Println("couldn't create one either :( exiting")
|
||||
os.Exit(1)
|
||||
|
@ -137,7 +156,10 @@ func main() {
|
|||
reader := bufio.NewReader(os.Stdin)
|
||||
packet := make([]byte, 65531)
|
||||
br, _ := reader.Read(packet)
|
||||
|
||||
if br > 65530 {
|
||||
fmt.Printf("sorry but i can't send more than 65530 bytes at once right now :( errorinn is working on it!\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
connection.SendPacket(packet[:br])
|
||||
case "receive":
|
||||
if len(os.Args) != 3 {
|
||||
|
|
Loading…
Reference in New Issue