<commit_before>package node

import (
	"log"
	"net"
	"time"
)

// The server handles creating connections and listening on various ports.
type Server struct {
	n         *Node
	listeners map[string]*SSHListener
}

func NewServer(key PrivateKey) *Server {
	n := NewNode(key, time.Tick(time.Second), time.Tick(time.Second))
	return &Server{n, make(map[string]*SSHListener)}
}

func (s *Server) Connect(addr string) error {
	c, err := net.Dial("tcp", addr)
	if err != nil {
		return err
	}
	sc, err := EstablishSSH(c, addr, s.n.id)
	if err != nil {
		return err
	}
	log.Printf("Outgoing connection: %v", sc)
	s.n.AddConnection(sc)
	return nil
}

func (s *Server) Listen(addr string) error {
	ln, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	l := ListenSSH(ln, s.n.id)
	if l.Error() != nil {
		return err
	}
	s.listeners[addr] = l
	go func() {
		for c := range l.Connections() {
			log.Printf("Incoming connection: %v", c)
			s.n.AddConnection(c)<commit_msg>Print connections in server.go using hex<commit_after>package node

import (
	"log"
	"net"
	"time"
)

// The server handles creating connections and listening on various ports.
type Server struct {
	n         *Node
	listeners map[string]*SSHListener
}

func NewServer(key PrivateKey) *Server {
	n := NewNode(key, time.Tick(time.Second), time.Tick(time.Second))
	return &Server{n, make(map[string]*SSHListener)}
}

func (s *Server) Connect(addr string) error {
	c, err := net.Dial("tcp", addr)
	if err != nil {
		return err
	}
	sc, err := EstablishSSH(c, addr, s.n.id)
	if err != nil {
		return err
	}
	log.Printf("Outgoing connection: %x", sc.Key().Hash())
	s.n.AddConnection(sc)
	return nil
}

func (s *Server) Listen(addr string) error {
	ln, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	l := ListenSSH(ln, s.n.id)
	if l.Error() != nil {
		return err
	}
	s.listeners[addr] = l
	go func() {
		for c := range l.Connections() {
			log.Printf("Incoming connection: %x", c.Key().Hash())
			s.n.AddConnection(c)
{'fraction_non_alphanumeric': 0.15726410384423364, 'fraction_numerical': 0.0, 'mean_word_length': 3.693208430913349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5338007', 'n_tokens_mistral': 774, 'n_tokens_neox': 756, 'n_words': 208}