mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-05 16:05:36 +00:00
71029cea2d
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"io"
|
|
"log"
|
|
"net/http"
|
|
"net/url"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
collection := flag.String("c", "", "logtail collection name")
|
|
publicID := flag.String("m", "", "machine public identifier")
|
|
apiKey := flag.String("p", "", "logtail API key")
|
|
flag.Parse()
|
|
if len(flag.Args()) != 0 {
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
log.SetFlags(0)
|
|
|
|
req, err := http.NewRequest("POST", "https://log.tailscale.io/instances", strings.NewReader(url.Values{
|
|
"collection": []string{*collection},
|
|
"instances": []string{*publicID},
|
|
"adopt": []string{"true"},
|
|
}.Encode()))
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
req.SetBasicAuth(*apiKey, "")
|
|
resp, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
b, err := io.ReadAll(resp.Body)
|
|
resp.Body.Close()
|
|
if err != nil {
|
|
log.Fatalf("logadopt: response read failed %d: %v", resp.StatusCode, err)
|
|
}
|
|
if resp.StatusCode != 200 {
|
|
log.Fatalf("adoption failed: %d: %s", resp.StatusCode, string(b))
|
|
}
|
|
log.Printf("%s", string(b))
|
|
}
|