Files
goSam/auth/main.go

59 lines
1.4 KiB
Go
Raw Normal View History

2022-04-28 11:23:54 -04:00
package main
import (
"fmt"
"log"
2022-04-28 11:23:54 -04:00
2024-11-13 14:39:08 -05:00
"github.com/go-i2p/gosam"
2022-04-28 11:23:54 -04:00
)
/**
2024-11-13 14:39:08 -05:00
THIS is a freestanding test for SAMv3.2 AUTH commands using gosam. It's
2022-04-28 11:23:54 -04:00
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() {
2024-11-13 14:39:08 -05:00
client, err := gosam.NewClientFromOptions()
2022-04-28 11:23:54 -04:00
if err != nil {
2024-11-13 14:39:08 -05:00
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)
2022-04-28 11:23:54 -04:00
panic(err)
}
err = client.SetupAuth("user", "password")
if err != nil {
log.Println(err)
2022-04-28 11:23:54 -04:00
}
2024-11-13 14:39:08 -05:00
client2, err := gosam.NewDefaultClient()
2022-04-28 11:23:54 -04:00
if err != nil {
log.Println(err)
2022-04-28 11:23:54 -04:00
}
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()
}