"github.com/rivo/tview"
"github.com/stretchr/testify/mock"
"go.uber.org/zap"
- "gopkg.in/yaml.v2"
+ "gopkg.in/yaml.v3"
"math/big"
"math/rand"
"net"
prefs := ClientPrefs{}
decoder := yaml.NewDecoder(fh)
- decoder.SetStrict(true)
if err := decoder.Decode(&prefs); err != nil {
return nil, err
}
prefs, err := readConfig(cfgPath)
if err != nil {
- fmt.Printf("unable to read config file %s", cfgPath)
- os.Exit(1)
+ logger.Fatal(fmt.Sprintf("unable to read config file %s\n", cfgPath))
}
c.pref = prefs
Handler: handleTranServerMsg,
},
tranKeepAlive: clientTransaction{
- Name: "tranKeepAlive",
+ Name: "tranKeepAlive",
Handler: func(client *Client, transaction *Transaction) (t []Transaction, err error) {
return t, err
},
newsTextView.SetBorder(true).SetTitle("News")
c.UI.Pages.AddPage("news", newsTextView, true, true)
- //c.UI.Pages.SwitchToPage("news")
- //c.UI.App.SetFocus(newsTextView)
+ // c.UI.Pages.SwitchToPage("news")
+ // c.UI.App.SetFocus(newsTextView)
c.UI.App.Draw()
return res, err
}
func (c *Client) Handshake() error {
- //Protocol ID 4 ‘TRTP’ 0x54 52 54 50
- //Sub-protocol ID 4 User defined
- //Version 2 1 Currently 1
- //Sub-version 2 User defined
+ // Protocol ID 4 ‘TRTP’ 0x54 52 54 50
+ // Sub-protocol ID 4 User defined
+ // Version 2 1 Currently 1
+ // Sub-version 2 User defined
if _, err := c.Connection.Write(ClientHandshake); err != nil {
return fmt.Errorf("handshake write err: %s", err)
}
requestNum := binary.BigEndian.Uint16(t.Type)
tID := binary.BigEndian.Uint32(t.ID)
- //handler := TransactionHandlers[requestNum]
+ // handler := TransactionHandlers[requestNum]
// if transaction is NOT reply, add it to the list to transactions we're expecting a response for
if t.IsReply == 0 {
return nil
}
-func (c *Client) Connected() bool {
- // c.Agreed == true &&
- if c.UserAccess != nil {
- return true
- }
- return false
-}
-
func (c *Client) Disconnect() error {
- err := c.Connection.Close()
- if err != nil {
- return err
- }
- return nil
+ return c.Connection.Close()
}