commit fe1216b
delthas
·
2023-08-10 09:27:29 +0000 UTC
parent 46ea446
Drop the cmd/test client It was untested and unused.
2 files changed,
+1,
-133
+1,
-7
1@@ -46,13 +46,7 @@ configuration options!
2
3 ## Debugging errors, testing servers
4
5-If you run into errors and want to find the WHY OH WHY, or if you'd like to try
6-things out with an IRC server, then you have two options:
7-
8-1. Run senpai with the `-debug` argument (or put `debug true`) in your config,
9- it will then print in `home` all the data it sends and receives.
10-2. Run the test client, that uses the same IRC library but exposes a simpler
11- interface, by running `go run ./cmd/test -help`.
12+To debug IRC traffic, run senpai with the `-debug` argument (or put `debug true`) in your config, it will then print in the `home` buffer all the data it sends and receives.
13
14 ## Issue tracker
15
+0,
-126
1@@ -1,126 +0,0 @@
2-package main
3-
4-import (
5- "crypto/tls"
6- "flag"
7- "fmt"
8- "io"
9- "net"
10- "os"
11- "path"
12-
13- "git.sr.ht/~taiite/senpai"
14- "git.sr.ht/~taiite/senpai/irc"
15- "golang.org/x/term"
16-)
17-
18-var (
19- configPath string
20- address string
21- nick string
22- password string
23- useTLS bool
24-)
25-
26-func main() {
27- parseFlags()
28-
29- oldState, err := term.MakeRaw(0)
30- if err != nil {
31- panic(err)
32- }
33- defer term.Restore(0, oldState)
34-
35- screen := struct {
36- io.Reader
37- io.Writer
38- }{os.Stdin, os.Stdout}
39- t := term.NewTerminal(screen, "> ")
40-
41- fmt.Fprintf(t, "Connecting to %s...\n", address)
42-
43- var conn net.Conn
44- if useTLS {
45- conn, err = tls.Dial("tcp", address, nil)
46- } else {
47- conn, err = net.Dial("tcp", address)
48- }
49- if err != nil {
50- panic(fmt.Sprintf("Failed to connect to %s: %v\n", address, err))
51- }
52- defer conn.Close()
53-
54- fmt.Fprintf(t, "Connected. Registration in progress...\n")
55-
56- var auth irc.SASLClient
57- if password != "" {
58- auth = &irc.SASLPlain{Username: nick, Password: password}
59- }
60-
61- in, out := irc.ChanInOut(conn)
62- debugOut := make(chan irc.Message, 64)
63- go func() {
64- for msg := range debugOut {
65- fmt.Fprintf(t, "C > S: %s\n", msg.String())
66- out <- msg
67- }
68- close(out)
69- }()
70-
71- cli := irc.NewSession(debugOut, irc.SessionParams{
72- Nickname: nick,
73- Username: nick,
74- RealName: nick,
75- Auth: auth,
76- })
77- defer cli.Close()
78-
79- go func() {
80- for {
81- line, err := t.ReadLine()
82- if err != nil {
83- break
84- }
85- cli.SendRaw(line)
86- }
87- cli.Close()
88- }()
89-
90- for msg := range in {
91- cli.HandleMessage(msg)
92- fmt.Fprintf(t, "C < S: %s\n", msg.String())
93- }
94- t.SetPrompt("")
95- fmt.Fprintln(t, "Disconnected")
96-}
97-
98-func parseFlags() {
99- flag.StringVar(&configPath, "config", "", "path to the configuration file")
100- flag.StringVar(&address, "address", "", "server address")
101- flag.StringVar(&nick, "nick", "senpai", "IRC nick/user to use")
102- flag.StringVar(&password, "password", "", "SASL password to use")
103- flag.BoolVar(&useTLS, "tls", false, "use tls")
104- flag.Parse()
105-
106- if address == "" {
107- if configPath == "" {
108- configDir, err := os.UserConfigDir()
109- if err != nil {
110- panic(err)
111- }
112- configPath = path.Join(configDir, "senpai", "senpai.scfg")
113- }
114-
115- cfg, err := senpai.LoadConfigFile(configPath)
116- if err != nil {
117- panic(err)
118- }
119-
120- address = cfg.Addr
121- nick = cfg.Nick
122- if cfg.Password != nil {
123- password = *cfg.Password
124- }
125- useTLS = cfg.TLS
126- }
127-}