Files
goSam/auth/main.go
2024-11-13 14:39:08 -05:00

59 lines
1.4 KiB
Go

package main
import (
"fmt"
"log"
"github.com/go-i2p/gosam"
)
/**
THIS is a freestanding test for SAMv3.2 AUTH commands using gosam. It's
intended to be run separate from the other tests so that you don't accidentally end
up setting SAM session passwords and leaving them in the PasswordManager if a test
fails for some reason before you can remove them.
**/
func main() {
client, err := gosam.NewClientFromOptions()
if err != nil {
client, err = gosam.NewClientFromOptions(
gosam.SetUser("user"),
gosam.SetPass("password"),
)
fmt.Println("Looks like you restarted the I2P router before sending AUTH DISABLE.")
fmt.Println("This probably means that your SAM Bridge is in a broken state where it can't")
fmt.Println("accept HELLO or AUTH commands anymore. You should fix this by removing the")
fmt.Println("sam.auth=true entry from sam.config.")
err = client.TeardownAuth()
if err != nil {
fmt.Println(err)
}
fmt.Println(err)
panic(err)
}
err = client.SetupAuth("user", "password")
if err != nil {
log.Println(err)
}
client2, err := gosam.NewDefaultClient()
if err != nil {
log.Println(err)
}
conn, err := client2.Dial("", "idk.i2p")
if err != nil {
fmt.Println(err)
}
conn.Close()
err = client.RemoveAuthUser("user")
if err != nil {
panic(err)
}
//fmt.Println(r)
err = client.TeardownAuth()
if err != nil {
panic(err)
}
//r, err = client.NewDestination()
}