package tcp

import (
	"fmt"
	"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
	"git.loafle.net/overflow/overflow_probe/discovery/discovery/types/timestamp"
	"testing"

	"github.com/google/gopacket/layers"
)

func TestPortScan(t *testing.T) {

	zone := types.NewZones()[0]

	hh := &types.DiscoveryHost{
		Ip_:            "192.168.1.215",
		Ports_:         make(map[string]*types.DiscoveryPort, 100),
		Ip:             111,
		Mac:            222,
		CreateDate:     timestamp.Now(),
		UpdateDate:     timestamp.Now(),
		Zone:           zone,
		FirstScanRange: 1,
		LastScanRange:  100,
	}

	Scan(hh, func(tcp *layers.TCP) {
		fmt.Println(tcp)
	})

}

func TestPortCheck(t *testing.T) {

	zone := types.NewZones()[0]

	hh := &types.DiscoveryHost{
		Ip_:            "192.168.1.215",
		Ports_:         make(map[string]*types.DiscoveryPort, 100),
		Ip:             111,
		Mac:            222,
		CreateDate:     timestamp.Now(),
		UpdateDate:     timestamp.Now(),
		Zone:           zone,
		FirstScanRange: 1,
		LastScanRange:  100,
	}

	var ports []*types.DiscoveryPort

	ports = append(ports, &types.DiscoveryPort{Number: 1})
	ports = append(ports, &types.DiscoveryPort{Number: 3})
	ports = append(ports, &types.DiscoveryPort{Number: 5})
	ports = append(ports, &types.DiscoveryPort{Number: 7})
	ports = append(ports, &types.DiscoveryPort{Number: 9})
	ports = append(ports, &types.DiscoveryPort{Number: 11})

	Check(hh, ports)

}
