Пример #1
0
func main() {
	opts := options.Client{}
	opts.Parse()

	if opts.ServerIP == "" {
		zc := zeroconf.NewClient("_goptyscreen._tcp.")
		zc.Dial()
		opts.ServerIP = zc.Host
		opts.Port = zc.Port
	}

	defer goncurses.End()
	_, err := goncurses.Init()
	if err != nil {
		panic(err)
	}

	goncurses.Cursor(0) // no cursor please
	goncurses.StartColor()

	list := pty_client.NewList(opts.ServerIP, opts.Port)
	list.Fetch()
	key_port, screen_port := list.GetSelection()
	goncurses.End()

	pty_client.Connect(opts.ServerIP, key_port, screen_port)
}
Пример #2
0
func NewSender(host string, port string, public_id string) *Sender {
	// give priority to host/port style
	if host != "" {
		return &Sender{
			host: host,
			port: port,
		}
	}

	zc := zeroconf.NewClient(go_pty_service)

	matcher := func(txtRecords map[string]string) bool {
		return txtRecords[public_id_key] == public_id &&
			txtRecords[private_id_key] != private_id // don't connect to yourself
	}

	for zc.Host == "" { // loop until a connection is available
		zc.DialWhenMatch(matcher)
	}

	zcStringPort := strconv.Itoa(zc.Port)
	return &Sender{
		host: zc.Host,
		port: zcStringPort,
	}

}