Make log messages more descriptive (#34)

master
HimbeerserverDE 2021-03-02 17:42:26 +01:00
parent aa12ddcee7
commit f78b91bf77
No known key found for this signature in database
GPG Key ID: 1A651504791E6A8B
3 changed files with 6 additions and 10 deletions

4
ban.go
View File

@ -4,13 +4,13 @@ import (
"database/sql"
"encoding/binary"
"errors"
"fmt"
"net"
"github.com/anon55555/mt/rudp"
_ "github.com/mattn/go-sqlite3"
)
var ErrAlreadyBanned = errors.New("ip address is already banned")
var ErrInvalidAddress = errors.New("invalid ip address format")
// addBanItem inserts a ban DB entry
@ -106,7 +106,7 @@ func (p *Peer) Ban() error {
}
if banned {
return ErrAlreadyBanned
return fmt.Errorf("ip address %s is already banned", p.Addr().String())
}
db, err := initAuthDB()

View File

@ -1,13 +1,11 @@
package main
import (
"errors"
"fmt"
"github.com/anon55555/mt"
)
var ErrNoHandCaps = errors.New("hand tool capabilities missing")
func (p *Peer) UpdateHandCapabs() error {
l := p.Inv().List("hand")
if l == nil {
@ -27,7 +25,7 @@ func (p *Peer) UpdateHandCapabs() error {
caps := handcapabs[p.ServerName()]
if caps == nil {
return ErrNoHandCaps
return fmt.Errorf("hand tool capabilities of server %s missing", p.ServerName())
}
s, err := caps.SerializeJSON()

View File

@ -1,7 +1,7 @@
package main
import (
"errors"
"fmt"
"net"
"sync"
"time"
@ -10,8 +10,6 @@ import (
"github.com/anon55555/mt/rudp"
)
var ErrServerUnreachable = errors.New("server is unreachable")
var connectedPeers int = 0
var connectedPeersMu sync.RWMutex
@ -136,7 +134,7 @@ func Connect(conn net.PacketConn, addr net.Addr) (*Peer, error) {
srv.SendDisco(0, true)
srv.Close()
return nil, ErrServerUnreachable
return nil, fmt.Errorf("server at %s is unreachable", addr.String())
case <-ack:
}