Example #1
0
	destTable,
}

var allDestIndices = []string{
	destPortIndex,
}

func init() {

	db.Readify()

	db.CreateTables(allDestTables)
	db.CreateIndices(destTable, allDestIndices)
}

var destPortRange = utils.NumberRange(10000, 11000)

type Destination struct {
	Id        string `gorethink:"id, omitempty"`
	LocalPort string `gorethink:"local_port"`
	NodeId    string `gorethink:"node_id"`
}

func NewDestination(nodeId string) (*Destination, error) {

	d := &Destination{
		LocalPort: "555",
		NodeId:    nodeId,
	}

	return d, nil
Example #2
0
import (
	"fmt"
	"os/exec"
	"strconv"
	"strings"

	"warp/utils"
)

const (
	sshPath     = "/usr/bin/ssh"
	netstatPath = "/bin/netstat"
	netstatArgs = "-tuln"
)

var portRange = utils.NumberRange(10000, 65535)

var remoteNetstat = netstatPath + " " + netstatArgs
var remoteNodeFmt string = "%s@%s"

// remoteNetstatCmd returns output of `netstat -tln` from a remote machine
// over SSH. That is, all used ports of a remote machine.
func remoteNetstatCmd(username string, host string) (string, error) {

	remoteNode := fmt.Sprintf(remoteNodeFmt, username, host)

	cmd := exec.Command(
		sshPath,
		remoteNode,
		remoteNetstat)