mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
34c04babbe
1. Change listen addresses to URIs 2. Break out connectionSvc to support listeners and dialers based on schema 3. Add relay announcement and lookups part of discovery service
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// Copyright (C) 2014 The Syncthing Authors.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/syncthing/protocol"
|
|
"github.com/syncthing/syncthing/lib/discover"
|
|
)
|
|
|
|
func main() {
|
|
log.SetFlags(0)
|
|
log.SetOutput(os.Stdout)
|
|
|
|
var server string
|
|
|
|
flag.StringVar(&server, "server", "udp4://announce.syncthing.net:22027", "Announce server")
|
|
flag.Parse()
|
|
|
|
if len(flag.Args()) != 1 || server == "" {
|
|
log.Printf("Usage: %s [-server=\"udp4://announce.syncthing.net:22027\"] <device>", os.Args[0])
|
|
os.Exit(64)
|
|
}
|
|
|
|
id, err := protocol.DeviceIDFromString(flag.Args()[0])
|
|
if err != nil {
|
|
log.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
discoverer := discover.NewDiscoverer(protocol.LocalDeviceID, nil, nil)
|
|
discoverer.StartGlobal([]string{server}, 1)
|
|
addresses, relays := discoverer.Lookup(id)
|
|
for _, addr := range addresses {
|
|
log.Println("address:", addr)
|
|
}
|
|
for _, addr := range relays {
|
|
log.Println("relay:", addr)
|
|
}
|
|
}
|