├── debian ├── compat ├── changelog └── control ├── .gitignore ├── vendor ├── golang.org │ └── x │ │ └── sys │ │ └── unix │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── constants.go │ │ ├── syscall_no_getwd.go │ │ ├── zsysnum_solaris_amd64.go │ │ ├── env_unset.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── flock_linux_32bit.go │ │ ├── asm_solaris_amd64.s │ │ ├── gccgo_linux_sparc64.go │ │ ├── gccgo_linux_amd64.go │ │ ├── race0.go │ │ ├── env_unix.go │ │ ├── syscall_unix_gc.go │ │ ├── asm_linux_arm64.s │ │ ├── str.go │ │ ├── race.go │ │ ├── asm_linux_s390x.s │ │ ├── asm_linux_ppc64x.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_mips64x.s │ │ ├── asm_freebsd_arm.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_darwin_386.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── bluetooth_linux.go │ │ ├── asm_darwin_arm64.s │ │ ├── asm_linux_mipsx.s │ │ ├── flock.go │ │ ├── asm_linux_386.s │ │ ├── syscall_solaris_amd64.go │ │ ├── openbsd_pledge.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_openbsd_386.go │ │ ├── gccgo_c.c │ │ ├── sockcmsg_linux.go │ │ ├── LICENSE │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_freebsd_386.go │ │ └── gccgo.go └── github.com │ ├── syncthing │ └── syncthing │ │ ├── vendor │ │ ├── github.com │ │ │ ├── calmh │ │ │ │ └── du │ │ │ │ │ ├── diskusage.go │ │ │ │ │ ├── diskusage_unsupported.go │ │ │ │ │ ├── cmd │ │ │ │ │ └── du │ │ │ │ │ │ └── main.go │ │ │ │ │ ├── diskusage_posix.go │ │ │ │ │ └── diskusage_windows.go │ │ │ ├── gobwas │ │ │ │ └── glob │ │ │ │ │ ├── util │ │ │ │ │ └── strings │ │ │ │ │ │ └── strings.go │ │ │ │ │ ├── syntax │ │ │ │ │ ├── syntax.go │ │ │ │ │ ├── ast │ │ │ │ │ │ └── ast.go │ │ │ │ │ └── lexer │ │ │ │ │ │ └── token.go │ │ │ │ │ ├── match │ │ │ │ │ ├── nothing.go │ │ │ │ │ ├── super.go │ │ │ │ │ ├── suffix.go │ │ │ │ │ ├── max.go │ │ │ │ │ ├── single.go │ │ │ │ │ ├── text.go │ │ │ │ │ ├── any.go │ │ │ │ │ ├── range.go │ │ │ │ │ ├── min.go │ │ │ │ │ ├── list.go │ │ │ │ │ ├── prefix.go │ │ │ │ │ ├── contains.go │ │ │ │ │ ├── prefix_suffix.go │ │ │ │ │ ├── row.go │ │ │ │ │ ├── any_of.go │ │ │ │ │ ├── match.go │ │ │ │ │ ├── debug │ │ │ │ │ │ └── debug.go │ │ │ │ │ └── segments.go │ │ │ │ │ └── cmd │ │ │ │ │ └── globdraw │ │ │ │ │ └── main.go │ │ │ └── petermattis │ │ │ │ └── goid │ │ │ │ ├── goid_go1.4.s │ │ │ │ ├── goid_go1.3.go │ │ │ │ ├── goid_go1.3.c │ │ │ │ ├── goid_slow.go │ │ │ │ ├── goid_go1.5plus.s │ │ │ │ ├── goid_go1.5plus_arm.s │ │ │ │ ├── goid.go │ │ │ │ ├── goid_go1.6plus.go │ │ │ │ ├── goid_go1.4.go │ │ │ │ └── goid_go1.5.go │ │ └── golang.org │ │ │ └── x │ │ │ ├── net │ │ │ ├── ipv4 │ │ │ │ ├── sys_linux_386.s │ │ │ │ ├── sys_solaris_amd64.s │ │ │ │ ├── sys_stub.go │ │ │ │ ├── sockopt_stub.go │ │ │ │ ├── bpfopt_stub.go │ │ │ │ ├── sockopt_asmreqn_stub.go │ │ │ │ ├── sockopt_ssmreq_stub.go │ │ │ │ ├── icmp_stub.go │ │ │ │ ├── payload.go │ │ │ │ ├── control_stub.go │ │ │ │ ├── icmp_linux.go │ │ │ │ ├── syscall_windows.go │ │ │ │ ├── sockopt_asmreq_stub.go │ │ │ │ ├── zsys_netbsd.go │ │ │ │ ├── zsys_openbsd.go │ │ │ │ ├── control_windows.go │ │ │ │ ├── zsys_dragonfly.go │ │ │ │ ├── bpfopt_linux.go │ │ │ │ ├── genericopt_stub.go │ │ │ │ ├── syscall_unix.go │ │ │ │ ├── syscall_linux_386.go │ │ │ │ ├── control_pktinfo.go │ │ │ │ ├── defs_netbsd.go │ │ │ │ ├── defs_openbsd.go │ │ │ │ ├── defs_dragonfly.go │ │ │ │ ├── control_bsd.go │ │ │ │ ├── sockopt_asmreqn_unix.go │ │ │ │ ├── sys_openbsd.go │ │ │ │ ├── sys_bsd.go │ │ │ │ ├── syscall_solaris.go │ │ │ │ ├── iana.go │ │ │ │ ├── sockopt_asmreq_posix.go │ │ │ │ ├── payload_nocmsg.go │ │ │ │ ├── helper.go │ │ │ │ ├── genericopt_posix.go │ │ │ │ ├── sockopt_ssmreq_unix.go │ │ │ │ ├── icmp.go │ │ │ │ ├── sockopt.go │ │ │ │ └── sys_windows.go │ │ │ ├── ipv6 │ │ │ │ ├── sys_linux_386.s │ │ │ │ ├── sys_solaris_amd64.s │ │ │ │ ├── sys_stub.go │ │ │ │ ├── sockopt_stub.go │ │ │ │ ├── bpfopt_stub.go │ │ │ │ ├── icmp_stub.go │ │ │ │ ├── sockopt_ssmreq_stub.go │ │ │ │ ├── payload.go │ │ │ │ ├── icmp_windows.go │ │ │ │ ├── control_stub.go │ │ │ │ ├── syscall_windows.go │ │ │ │ ├── sockopt_asmreq_posix.go │ │ │ │ ├── icmp_linux.go │ │ │ │ ├── icmp_solaris.go │ │ │ │ ├── control_windows.go │ │ │ │ ├── icmp_bsd.go │ │ │ │ ├── bpfopt_linux.go │ │ │ │ ├── syscall_unix.go │ │ │ │ ├── genericopt_stub.go │ │ │ │ ├── syscall_linux_386.go │ │ │ │ ├── helper.go │ │ │ │ ├── syscall_solaris.go │ │ │ │ ├── payload_nocmsg.go │ │ │ │ ├── sockopt_ssmreq_unix.go │ │ │ │ ├── header.go │ │ │ │ ├── control_rfc2292_unix.go │ │ │ │ ├── genericopt_posix.go │ │ │ │ ├── icmp.go │ │ │ │ └── zsys_netbsd.go │ │ │ ├── internal │ │ │ │ └── netreflect │ │ │ │ │ ├── socket_stub.go │ │ │ │ │ ├── socket_posix.go │ │ │ │ │ ├── socket_19.go │ │ │ │ │ └── socket.go │ │ │ ├── proxy │ │ │ │ └── direct.go │ │ │ └── bpf │ │ │ │ └── asm.go │ │ │ └── text │ │ │ └── unicode │ │ │ └── norm │ │ │ └── trie.go │ │ └── lib │ │ ├── osutil │ │ ├── fsroots_unix.go │ │ ├── lstat_ok.go │ │ ├── mkdirall.go │ │ ├── glob_unix.go │ │ ├── rlimit_windows.go │ │ ├── hidden_unix.go │ │ ├── filenames_darwin.go │ │ ├── filenames_unix.go │ │ ├── filenames_windows.go │ │ ├── lan.go │ │ ├── sync.go │ │ ├── lstat_broken.go │ │ ├── replacingwriter.go │ │ ├── ping.go │ │ ├── fsroots_windows.go │ │ ├── hidden_windows.go │ │ └── rlimit_unix.go │ │ ├── sync │ │ └── debug.go │ │ └── ignore │ │ ├── cache.go │ │ └── tempname.go │ ├── zillode │ └── notify │ │ ├── debug.go │ │ ├── event_trigger.go │ │ ├── tree.go │ │ ├── watchpoint_other.go │ │ ├── watcher_stub.go │ │ ├── debug_debug.go │ │ ├── event_stub.go │ │ ├── LICENSE │ │ └── watchpoint_readdcw.go │ └── cenkalti │ └── backoff │ ├── LICENSE │ ├── retry.go │ └── ticker.go ├── rlimit_windows.go ├── etc ├── linux-systemd │ ├── user │ │ └── syncthing-inotify.service │ └── system │ │ └── syncthing-inotify@.service └── macosx-launchd │ ├── README.md │ └── syncthing-inotify.plist ├── cross-compile-xgo.rb └── rlimit_unix.go /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | /syncthing-inotify* 3 | /Godeps/_workspace 4 | /Godeps/Readme 5 | deb 6 | *.deb 7 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | syncthing-inotify ({{version}}); urgency=medium 2 | 3 | * Packaging of {{version}}. 4 | 5 | -- {{mntner}} {{date}} 6 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Package: syncthing-inotify 2 | Architecture: {{arch}} 3 | Depends: libc6 4 | Version: {{version}} 5 | Maintainer: {{mntner}} 6 | Description: File watcher intended for use with Syncthing 7 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/calmh/du/diskusage.go: -------------------------------------------------------------------------------- 1 | package du 2 | 3 | // Usage holds information about total and available storage on a volume. 4 | type Usage struct { 5 | TotalBytes int64 // Size of volume 6 | FreeBytes int64 // Unused size 7 | AvailBytes int64 // Available to a non-privileged user 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/util/strings/strings.go: -------------------------------------------------------------------------------- 1 | package strings 2 | 3 | import "strings" 4 | 5 | func IndexAnyRunes(s string, rs []rune) int { 6 | for _, r := range rs { 7 | if i := strings.IndexRune(s, r); i != -1 { 8 | return i 9 | } 10 | } 11 | 12 | return -1 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sys_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·socketcall(SB),NOSPLIT,$0-36 8 | JMP syscall·socketcall(SB) 9 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/sys_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·socketcall(SB),NOSPLIT,$0-36 8 | JMP syscall·socketcall(SB) 9 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sys_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 8 | JMP syscall·sysvicall6(SB) 9 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/sys_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 8 | JMP syscall·sysvicall6(SB) 9 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // +build !debug 6 | 7 | package notify 8 | 9 | func dbgprint(...interface{}) {} 10 | 11 | func dbgprintf(string, ...interface{}) {} 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/syntax/syntax.go: -------------------------------------------------------------------------------- 1 | package syntax 2 | 3 | import ( 4 | "github.com/gobwas/glob/syntax/ast" 5 | "github.com/gobwas/glob/syntax/lexer" 6 | ) 7 | 8 | func Parse(s string) (*ast.Node, error) { 9 | return ast.Parse(lexer.NewLexer(s)) 10 | } 11 | 12 | func Special(b byte) bool { 13 | return lexer.Special(b) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sys_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv4 8 | 9 | var ( 10 | ctlOpts = [ctlMax]ctlOpt{} 11 | 12 | sockOpts = [ssoMax]sockOpt{} 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/sys_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv6 8 | 9 | var ( 10 | ctlOpts = [ctlMax]ctlOpt{} 11 | 12 | sockOpts = [ssoMax]sockOpt{} 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv4 8 | 9 | func setInt(s uintptr, opt *sockOpt, v int) error { 10 | return errOpNoSupport 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/calmh/du/diskusage_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build netbsd openbsd solaris 2 | 3 | package du 4 | 5 | import "errors" 6 | 7 | var ErrUnsupported = errors.New("unsupported platform") 8 | 9 | // Get returns the Usage of a given path, or an error if usage data is 10 | // unavailable. 11 | func Get(path string) (Usage, error) { 12 | return Usage{}, ErrUnsupported 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/sockopt_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv6 8 | 9 | import "net" 10 | 11 | func getMTUInfo(s uintptr, opt *sockOpt) (*net.Interface, int, error) { 12 | return nil, 0, errOpNoSupport 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/fsroots_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package osutil 10 | 11 | func GetFilesystemRoots() ([]string, error) { 12 | return []string{"/"}, nil 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /rlimit_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package main 10 | 11 | import ( 12 | "errors" 13 | ) 14 | 15 | func MaximizeOpenFileLimit() (int, error) { 16 | return 0, errors.New("not relevant on Windows") 17 | } 18 | -------------------------------------------------------------------------------- /etc/linux-systemd/user/syncthing-inotify.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Syncthing Inotify File Watcher 3 | Documentation=https://github.com/syncthing/syncthing-inotify/blob/master/README.md 4 | After=syncthing.service 5 | Requires=syncthing.service 6 | 7 | [Service] 8 | ExecStart=/usr/bin/syncthing-inotify -logflags=0 9 | SuccessExitStatus=2 10 | RestartForceExitStatus=3 11 | Restart=on-failure 12 | ProtectSystem=full 13 | ProtectHome=read-only 14 | 15 | [Install] 16 | WantedBy=default.target 17 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/lstat_ok.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !linux,!android 8 | 9 | package osutil 10 | 11 | import "os" 12 | 13 | func Lstat(name string) (fi os.FileInfo, err error) { 14 | return os.Lstat(name) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/internal/netreflect/socket_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.9 6 | // +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows 7 | 8 | package netreflect 9 | 10 | import "net" 11 | 12 | func socketOf(c net.Conn) (uintptr, error) { return 0, errOpNoSupport } 13 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/calmh/du/cmd/du/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | 8 | "github.com/calmh/du" 9 | ) 10 | 11 | var KB = int64(1024) 12 | 13 | func main() { 14 | usage, err := du.Get(os.Args[1]) 15 | if err != nil { 16 | log.Fatal(err) 17 | } 18 | fmt.Println("Free:", usage.FreeBytes/(KB*KB), "MiB") 19 | fmt.Println("Available:", usage.AvailBytes/(KB*KB), "MiB") 20 | fmt.Println("Size:", usage.TotalBytes/(KB*KB), "MiB") 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/mkdirall.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package osutil 10 | 11 | import ( 12 | "os" 13 | ) 14 | 15 | func MkdirAll(path string, perm os.FileMode) error { 16 | return os.MkdirAll(path, perm) 17 | } 18 | -------------------------------------------------------------------------------- /etc/linux-systemd/system/syncthing-inotify@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Syncthing Inotify File Watcher for %I 3 | Documentation=https://github.com/syncthing/syncthing-inotify/blob/master/README.md 4 | After=network.target syncthing@.service 5 | Requires=syncthing@.service 6 | 7 | [Service] 8 | User=%i 9 | ExecStart=/usr/bin/syncthing-inotify -logflags=0 10 | SuccessExitStatus=2 11 | RestartForceExitStatus=3 12 | Restart=on-failure 13 | ProtectSystem=full 14 | ProtectHome=read-only 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/glob_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package osutil 10 | 11 | import ( 12 | "path/filepath" 13 | ) 14 | 15 | func Glob(pattern string) (matches []string, err error) { 16 | return filepath.Glob(pattern) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/rlimit_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package osutil 10 | 11 | import ( 12 | "errors" 13 | ) 14 | 15 | func MaximizeOpenFileLimit() (int, error) { 16 | return 0, errors.New("not relevant on Windows") 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/bpfopt_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !linux 6 | 7 | package ipv4 8 | 9 | import "golang.org/x/net/bpf" 10 | 11 | // SetBPF attaches a BPF program to the connection. 12 | // 13 | // Only supported on Linux. 14 | func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { 15 | return errOpNoSupport 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/bpfopt_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !linux 6 | 7 | package ipv6 8 | 9 | import "golang.org/x/net/bpf" 10 | 11 | // SetBPF attaches a BPF program to the connection. 12 | // 13 | // Only supported on Linux. 14 | func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { 15 | return errOpNoSupport 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/hidden_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package osutil 10 | 11 | func HideFile(path string) error { 12 | return nil 13 | } 14 | 15 | func ShowFile(path string) error { 16 | return nil 17 | } 18 | 19 | func HideConsole() {} 20 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/proxy/direct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proxy 6 | 7 | import ( 8 | "net" 9 | ) 10 | 11 | type direct struct{} 12 | 13 | // Direct is a direct proxy: one that makes network connections directly. 14 | var Direct = direct{} 15 | 16 | func (direct) Dial(network, addr string) (net.Conn, error) { 17 | return net.Dial(network, addr) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/nothing.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Nothing struct{} 8 | 9 | func NewNothing() Nothing { 10 | return Nothing{} 11 | } 12 | 13 | func (self Nothing) Match(s string) bool { 14 | return len(s) == 0 15 | } 16 | 17 | func (self Nothing) Index(s string) (int, []int) { 18 | return 0, segments0 19 | } 20 | 21 | func (self Nothing) Len() int { 22 | return lenZero 23 | } 24 | 25 | func (self Nothing) String() string { 26 | return fmt.Sprintf("") 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/filenames_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import "golang.org/x/text/unicode/norm" 10 | 11 | func NormalizedFilename(s string) string { 12 | return norm.NFC.String(s) 13 | } 14 | 15 | func NativeFilename(s string) string { 16 | return norm.NFD.String(s) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !darwin,!freebsd,!linux 6 | 7 | package ipv4 8 | 9 | import "net" 10 | 11 | func getsockoptIPMreqn(s uintptr, name int) (*net.Interface, error) { 12 | return nil, errOpNoSupport 13 | } 14 | 15 | func setsockoptIPMreqn(s uintptr, name int, ifi *net.Interface, grp net.IP) error { 16 | return errOpNoSupport 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/filenames_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows,!darwin 8 | 9 | package osutil 10 | 11 | import "golang.org/x/text/unicode/norm" 12 | 13 | func NormalizedFilename(s string) string { 14 | return norm.NFC.String(s) 15 | } 16 | 17 | func NativeFilename(s string) string { 18 | return s 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/icmp_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv6 8 | 9 | type icmpv6Filter struct { 10 | } 11 | 12 | func (f *icmpv6Filter) accept(typ ICMPType) { 13 | } 14 | 15 | func (f *icmpv6Filter) block(typ ICMPType) { 16 | } 17 | 18 | func (f *icmpv6Filter) setAll(block bool) { 19 | } 20 | 21 | func (f *icmpv6Filter) willBlock(typ ICMPType) bool { 22 | return false 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !darwin,!freebsd,!linux,!solaris 6 | 7 | package ipv4 8 | 9 | import "net" 10 | 11 | func setsockoptGroupReq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { 12 | return errOpNoSupport 13 | } 14 | 15 | func setsockoptGroupSourceReq(s uintptr, name int, ifi *net.Interface, grp, src net.IP) error { 16 | return errOpNoSupport 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !darwin,!freebsd,!linux,!solaris 6 | 7 | package ipv6 8 | 9 | import "net" 10 | 11 | func setsockoptGroupReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { 12 | return errOpNoSupport 13 | } 14 | 15 | func setsockoptGroupSourceReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { 16 | return errOpNoSupport 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/icmp_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !linux 6 | 7 | package ipv4 8 | 9 | const sizeofICMPFilter = 0x0 10 | 11 | type icmpFilter struct { 12 | } 13 | 14 | func (f *icmpFilter) accept(typ ICMPType) { 15 | } 16 | 17 | func (f *icmpFilter) block(typ ICMPType) { 18 | } 19 | 20 | func (f *icmpFilter) setAll(block bool) { 21 | } 22 | 23 | func (f *icmpFilter) willBlock(typ ICMPType) bool { 24 | return false 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/filenames_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "path/filepath" 11 | 12 | "golang.org/x/text/unicode/norm" 13 | ) 14 | 15 | func NormalizedFilename(s string) string { 16 | return norm.NFC.String(filepath.ToSlash(s)) 17 | } 18 | 19 | func NativeFilename(s string) string { 20 | return filepath.FromSlash(s) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.4.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Assembly to get into package runtime without using exported symbols. 6 | // See https://github.com/golang/go/blob/release-branch.go1.4/misc/cgo/test/backdoor/thunk.s 7 | 8 | // +build amd64 amd64p32 arm 386 9 | // +build go1.4,!go1.5 10 | 11 | #include "textflag.h" 12 | 13 | #ifdef GOARCH_arm 14 | #define JMP B 15 | #endif 16 | 17 | TEXT ·getg(SB),NOSPLIT,$0-0 18 | JMP runtime·getg(SB) 19 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/payload.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import "net" 8 | 9 | // BUG(mikio): On Windows, the ControlMessage for ReadFrom and WriteTo 10 | // methods of PacketConn is not implemented. 11 | 12 | // A payloadHandler represents the IPv4 datagram payload handler. 13 | type payloadHandler struct { 14 | net.PacketConn 15 | rawOpt 16 | } 17 | 18 | func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil } 19 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/payload.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import "net" 8 | 9 | // BUG(mikio): On Windows, the ControlMessage for ReadFrom and WriteTo 10 | // methods of PacketConn is not implemented. 11 | 12 | // A payloadHandler represents the IPv6 datagram payload handler. 13 | type payloadHandler struct { 14 | net.PacketConn 15 | rawOpt 16 | } 17 | 18 | func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/event_trigger.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // +build darwin,kqueue dragonfly freebsd netbsd openbsd solaris 6 | 7 | package notify 8 | 9 | type event struct { 10 | p string 11 | e Event 12 | d bool 13 | pe interface{} 14 | } 15 | 16 | func (e *event) Event() Event { return e.e } 17 | 18 | func (e *event) Path() string { return e.p } 19 | 20 | func (e *event) Sys() interface{} { return e.pe } 21 | 22 | func (e *event) isDir() (bool, error) { return e.d, nil } 23 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/tree.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | package notify 6 | 7 | const buffer = 128 8 | 9 | type tree interface { 10 | Watch(string, chan<- EventInfo, func(string) bool, ...Event) error 11 | Stop(chan<- EventInfo) 12 | Close() error 13 | } 14 | 15 | func newTree() tree { 16 | c := make(chan EventInfo, buffer) 17 | w := newWatcher(c) 18 | if rw, ok := w.(recursiveWatcher); ok { 19 | return newRecursiveTree(rw, c) 20 | } 21 | return newNonrecursiveTree(w, c, make(chan EventInfo, buffer)) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/icmp_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | func (f *icmpv6Filter) accept(typ ICMPType) { 8 | // TODO(mikio): implement this 9 | } 10 | 11 | func (f *icmpv6Filter) block(typ ICMPType) { 12 | // TODO(mikio): implement this 13 | } 14 | 15 | func (f *icmpv6Filter) setAll(block bool) { 16 | // TODO(mikio): implement this 17 | } 18 | 19 | func (f *icmpv6Filter) willBlock(typ ICMPType) bool { 20 | // TODO(mikio): implement this 21 | return false 22 | } 23 | -------------------------------------------------------------------------------- /etc/macosx-launchd/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an example for running Syncthing-inotify in the 2 | background under Mac OS X. 3 | 4 | 1. Install the `syncthing-inotify` binary in a directory called `bin` in your 5 | home directory. 6 | 7 | 2. Edit the `syncthing-inotify.plist` by replacing `USERNAME` with your actual 8 | username such as `jb`. 9 | 10 | 3. Copy the `syncthing-inotify.plist` file to `~/Library/LaunchAgents`. 11 | 12 | 4. Log out and in again, or run `launchctl load ~/Library/LaunchAgents/syncthing-inotify.plist`. 13 | 14 | Logs are in `~/Library/Logs/Syncthing-inotify.log` and, for crashes and exceptions, 15 | `~/Library/Logs/Syncthing-inotify-errors.log`. 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/super.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Super struct{} 8 | 9 | func NewSuper() Super { 10 | return Super{} 11 | } 12 | 13 | func (self Super) Match(s string) bool { 14 | return true 15 | } 16 | 17 | func (self Super) Len() int { 18 | return lenNo 19 | } 20 | 21 | func (self Super) Index(s string) (int, []int) { 22 | segments := acquireSegments(len(s) + 1) 23 | for i := range s { 24 | segments = append(segments, i) 25 | } 26 | segments = append(segments, len(s)) 27 | 28 | return 0, segments 29 | } 30 | 31 | func (self Super) String() string { 32 | return fmt.Sprintf("") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/control_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv4 8 | 9 | func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { 10 | return errOpNoSupport 11 | } 12 | 13 | func newControlMessage(opt *rawOpt) []byte { 14 | return nil 15 | } 16 | 17 | func parseControlMessage(b []byte) (*ControlMessage, error) { 18 | return nil, errOpNoSupport 19 | } 20 | 21 | func marshalControlMessage(cm *ControlMessage) []byte { 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/control_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv6 8 | 9 | func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { 10 | return errOpNoSupport 11 | } 12 | 13 | func newControlMessage(opt *rawOpt) (oob []byte) { 14 | return nil 15 | } 16 | 17 | func parseControlMessage(b []byte) (*ControlMessage, error) { 18 | return nil, errOpNoSupport 19 | } 20 | 21 | func marshalControlMessage(cm *ControlMessage) (oob []byte) { 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/calmh/du/diskusage_posix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!netbsd,!openbsd,!solaris 2 | 3 | package du 4 | 5 | import ( 6 | "path/filepath" 7 | "syscall" 8 | ) 9 | 10 | // Get returns the Usage of a given path, or an error if usage data is 11 | // unavailable. 12 | func Get(path string) (Usage, error) { 13 | var stat syscall.Statfs_t 14 | err := syscall.Statfs(filepath.Clean(path), &stat) 15 | if err != nil { 16 | return Usage{}, err 17 | } 18 | u := Usage{ 19 | FreeBytes: int64(stat.Bfree) * int64(stat.Bsize), 20 | TotalBytes: int64(stat.Blocks) * int64(stat.Bsize), 21 | AvailBytes: int64(stat.Bavail) * int64(stat.Bsize), 22 | } 23 | return u, nil 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/icmp_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | func (f *icmpFilter) accept(typ ICMPType) { 8 | f.Data &^= 1 << (uint32(typ) & 31) 9 | } 10 | 11 | func (f *icmpFilter) block(typ ICMPType) { 12 | f.Data |= 1 << (uint32(typ) & 31) 13 | } 14 | 15 | func (f *icmpFilter) setAll(block bool) { 16 | if block { 17 | f.Data = 1<<32 - 1 18 | } else { 19 | f.Data = 0 20 | } 21 | } 22 | 23 | func (f *icmpFilter) willBlock(typ ICMPType) bool { 24 | return f.Data&(1<<(uint32(typ)&31)) != 0 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/syscall_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 13 | return syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), (*int32)(unsafe.Pointer(l))) 14 | } 15 | 16 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 17 | return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), int32(l)) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/syscall_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 13 | return syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), (*int32)(unsafe.Pointer(l))) 14 | } 15 | 16 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 17 | return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), int32(l)) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/lan.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "net" 11 | ) 12 | 13 | func GetLans() ([]*net.IPNet, error) { 14 | addrs, err := net.InterfaceAddrs() 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | nets := make([]*net.IPNet, 0, len(addrs)) 20 | 21 | for _, addr := range addrs { 22 | net, ok := addr.(*net.IPNet) 23 | if ok { 24 | nets = append(nets, net) 25 | } 26 | } 27 | return nets, nil 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!windows 6 | 7 | package ipv4 8 | 9 | import "net" 10 | 11 | func setsockoptIPMreq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { 12 | return errOpNoSupport 13 | } 14 | 15 | func getsockoptInterface(s uintptr, name int) (*net.Interface, error) { 16 | return nil, errOpNoSupport 17 | } 18 | 19 | func setsockoptInterface(s uintptr, name int, ifi *net.Interface) error { 20 | return errOpNoSupport 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/sockopt_asmreq_posix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris windows 6 | 7 | package ipv6 8 | 9 | import ( 10 | "net" 11 | "os" 12 | "unsafe" 13 | ) 14 | 15 | func setsockoptIPMreq(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { 16 | var mreq ipv6Mreq 17 | copy(mreq.Multiaddr[:], grp) 18 | if ifi != nil { 19 | mreq.setIfindex(ifi.Index) 20 | } 21 | return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, unsafe.Pointer(&mreq), sizeofIPv6Mreq)) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/suffix.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type Suffix struct { 9 | Suffix string 10 | } 11 | 12 | func NewSuffix(s string) Suffix { 13 | return Suffix{s} 14 | } 15 | 16 | func (self Suffix) Len() int { 17 | return lenNo 18 | } 19 | 20 | func (self Suffix) Match(s string) bool { 21 | return strings.HasSuffix(s, self.Suffix) 22 | } 23 | 24 | func (self Suffix) Index(s string) (int, []int) { 25 | idx := strings.Index(s, self.Suffix) 26 | if idx == -1 { 27 | return -1, nil 28 | } 29 | 30 | return 0, []int{idx + len(self.Suffix)} 31 | } 32 | 33 | func (self Suffix) String() string { 34 | return fmt.Sprintf("", self.Suffix) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/icmp_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | func (f *icmpv6Filter) accept(typ ICMPType) { 8 | f.Data[typ>>5] &^= 1 << (uint32(typ) & 31) 9 | } 10 | 11 | func (f *icmpv6Filter) block(typ ICMPType) { 12 | f.Data[typ>>5] |= 1 << (uint32(typ) & 31) 13 | } 14 | 15 | func (f *icmpv6Filter) setAll(block bool) { 16 | for i := range f.Data { 17 | if block { 18 | f.Data[i] = 1<<32 - 1 19 | } else { 20 | f.Data[i] = 0 21 | } 22 | } 23 | } 24 | 25 | func (f *icmpv6Filter) willBlock(typ ICMPType) bool { 26 | return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/zsys_netbsd.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs defs_netbsd.go 3 | 4 | package ipv4 5 | 6 | const ( 7 | sysIP_OPTIONS = 0x1 8 | sysIP_HDRINCL = 0x2 9 | sysIP_TOS = 0x3 10 | sysIP_TTL = 0x4 11 | sysIP_RECVOPTS = 0x5 12 | sysIP_RECVRETOPTS = 0x6 13 | sysIP_RECVDSTADDR = 0x7 14 | sysIP_RETOPTS = 0x8 15 | sysIP_RECVIF = 0x14 16 | sysIP_RECVTTL = 0x17 17 | 18 | sysIP_MULTICAST_IF = 0x9 19 | sysIP_MULTICAST_TTL = 0xa 20 | sysIP_MULTICAST_LOOP = 0xb 21 | sysIP_ADD_MEMBERSHIP = 0xc 22 | sysIP_DROP_MEMBERSHIP = 0xd 23 | 24 | sizeofIPMreq = 0x8 25 | ) 26 | 27 | type ipMreq struct { 28 | Multiaddr [4]byte /* in_addr */ 29 | Interface [4]byte /* in_addr */ 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/zsys_openbsd.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs defs_openbsd.go 3 | 4 | package ipv4 5 | 6 | const ( 7 | sysIP_OPTIONS = 0x1 8 | sysIP_HDRINCL = 0x2 9 | sysIP_TOS = 0x3 10 | sysIP_TTL = 0x4 11 | sysIP_RECVOPTS = 0x5 12 | sysIP_RECVRETOPTS = 0x6 13 | sysIP_RECVDSTADDR = 0x7 14 | sysIP_RETOPTS = 0x8 15 | sysIP_RECVIF = 0x1e 16 | sysIP_RECVTTL = 0x1f 17 | 18 | sysIP_MULTICAST_IF = 0x9 19 | sysIP_MULTICAST_TTL = 0xa 20 | sysIP_MULTICAST_LOOP = 0xb 21 | sysIP_ADD_MEMBERSHIP = 0xc 22 | sysIP_DROP_MEMBERSHIP = 0xd 23 | 24 | sizeofIPMreq = 0x8 25 | ) 26 | 27 | type ipMreq struct { 28 | Multiaddr [4]byte /* in_addr */ 29 | Interface [4]byte /* in_addr */ 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/control_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import "syscall" 8 | 9 | func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { 10 | // TODO(mikio): implement this 11 | return syscall.EWINDOWS 12 | } 13 | 14 | func newControlMessage(opt *rawOpt) []byte { 15 | // TODO(mikio): implement this 16 | return nil 17 | } 18 | 19 | func parseControlMessage(b []byte) (*ControlMessage, error) { 20 | // TODO(mikio): implement this 21 | return nil, syscall.EWINDOWS 22 | } 23 | 24 | func marshalControlMessage(cm *ControlMessage) []byte { 25 | // TODO(mikio): implement this 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs defs_dragonfly.go 3 | 4 | package ipv4 5 | 6 | const ( 7 | sysIP_OPTIONS = 0x1 8 | sysIP_HDRINCL = 0x2 9 | sysIP_TOS = 0x3 10 | sysIP_TTL = 0x4 11 | sysIP_RECVOPTS = 0x5 12 | sysIP_RECVRETOPTS = 0x6 13 | sysIP_RECVDSTADDR = 0x7 14 | sysIP_RETOPTS = 0x8 15 | sysIP_RECVIF = 0x14 16 | sysIP_RECVTTL = 0x41 17 | 18 | sysIP_MULTICAST_IF = 0x9 19 | sysIP_MULTICAST_TTL = 0xa 20 | sysIP_MULTICAST_LOOP = 0xb 21 | sysIP_MULTICAST_VIF = 0xe 22 | sysIP_ADD_MEMBERSHIP = 0xc 23 | sysIP_DROP_MEMBERSHIP = 0xd 24 | 25 | sizeofIPMreq = 0x8 26 | ) 27 | 28 | type ipMreq struct { 29 | Multiaddr [4]byte /* in_addr */ 30 | Interface [4]byte /* in_addr */ 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/icmp_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | func (f *icmpv6Filter) accept(typ ICMPType) { 8 | f.X__icmp6_filt[typ>>5] |= 1 << (uint32(typ) & 31) 9 | } 10 | 11 | func (f *icmpv6Filter) block(typ ICMPType) { 12 | f.X__icmp6_filt[typ>>5] &^= 1 << (uint32(typ) & 31) 13 | } 14 | 15 | func (f *icmpv6Filter) setAll(block bool) { 16 | for i := range f.X__icmp6_filt { 17 | if block { 18 | f.X__icmp6_filt[i] = 0 19 | } else { 20 | f.X__icmp6_filt[i] = 1<<32 - 1 21 | } 22 | } 23 | } 24 | 25 | func (f *icmpv6Filter) willBlock(typ ICMPType) bool { 26 | return f.X__icmp6_filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/control_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import "syscall" 8 | 9 | func setControlMessage(s uintptr, opt *rawOpt, cf ControlFlags, on bool) error { 10 | // TODO(mikio): implement this 11 | return syscall.EWINDOWS 12 | } 13 | 14 | func newControlMessage(opt *rawOpt) (oob []byte) { 15 | // TODO(mikio): implement this 16 | return nil 17 | } 18 | 19 | func parseControlMessage(b []byte) (*ControlMessage, error) { 20 | // TODO(mikio): implement this 21 | return nil, syscall.EWINDOWS 22 | } 23 | 24 | func marshalControlMessage(cm *ControlMessage) (oob []byte) { 25 | // TODO(mikio): implement this 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/icmp_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package ipv6 8 | 9 | func (f *icmpv6Filter) accept(typ ICMPType) { 10 | f.Filt[typ>>5] |= 1 << (uint32(typ) & 31) 11 | } 12 | 13 | func (f *icmpv6Filter) block(typ ICMPType) { 14 | f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31) 15 | } 16 | 17 | func (f *icmpv6Filter) setAll(block bool) { 18 | for i := range f.Filt { 19 | if block { 20 | f.Filt[i] = 0 21 | } else { 22 | f.Filt[i] = 1<<32 - 1 23 | } 24 | } 25 | } 26 | 27 | func (f *icmpv6Filter) willBlock(typ ICMPType) bool { 28 | return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/calmh/du/diskusage_windows.go: -------------------------------------------------------------------------------- 1 | package du 2 | 3 | import ( 4 | "runtime" 5 | "syscall" 6 | "unsafe" 7 | ) 8 | 9 | // Get returns the Usage of a given path, or an error if usage data is 10 | // unavailable. 11 | func Get(path string) (Usage, error) { 12 | h := syscall.MustLoadDLL("kernel32.dll") 13 | c := h.MustFindProc("GetDiskFreeSpaceExW") 14 | 15 | var u Usage 16 | 17 | pathw, err := syscall.UTF16PtrFromString(path) 18 | if err != nil { 19 | return Usage{}, err 20 | } 21 | 22 | ret, _, err := c.Call( 23 | uintptr(unsafe.Pointer(pathw)), 24 | uintptr(unsafe.Pointer(&u.FreeBytes)), 25 | uintptr(unsafe.Pointer(&u.TotalBytes)), 26 | uintptr(unsafe.Pointer(&u.AvailBytes))) 27 | runtime.KeepAlive(pathw) 28 | 29 | if ret == 0 { 30 | return Usage{}, err 31 | } 32 | 33 | return u, nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/watchpoint_other.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // +build !windows 6 | 7 | package notify 8 | 9 | // eventmask uses ei to create a new event which contains internal flags used by 10 | // notify package logic. 11 | func eventmask(ei EventInfo, extra Event) Event { 12 | return ei.Event() | extra 13 | } 14 | 15 | // matches reports a match only when: 16 | // 17 | // - for user events, when event is present in the given set 18 | // - for internal events, when additionally both event and set have omit bit set 19 | // 20 | // Internal events must not be sent to user channels and vice versa. 21 | func matches(set, event Event) bool { 22 | return (set&omit)^(event&omit) == 0 && set&event == event 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/watcher_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows 6 | // +build !kqueue,!solaris 7 | 8 | package notify 9 | 10 | import "errors" 11 | 12 | type stub struct{ error } 13 | 14 | // newWatcher stub. 15 | func newWatcher(chan<- EventInfo) watcher { 16 | return stub{errors.New("notify: not implemented")} 17 | } 18 | 19 | // Following methods implement notify.watcher interface. 20 | func (s stub) Watch(string, Event) error { return s } 21 | func (s stub) Rewatch(string, Event, Event) error { return s } 22 | func (s stub) Unwatch(string) (err error) { return s } 23 | func (s stub) Close() error { return s } 24 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/sync.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "os" 11 | "runtime" 12 | ) 13 | 14 | func SyncFile(path string) error { 15 | flag := 0 16 | if runtime.GOOS == "windows" { 17 | flag = os.O_WRONLY 18 | } 19 | fd, err := os.OpenFile(path, flag, 0) 20 | if err != nil { 21 | return err 22 | } 23 | defer fd.Close() 24 | // MacOS and Windows do not flush the disk cache 25 | return fd.Sync() 26 | } 27 | 28 | func SyncDir(path string) error { 29 | if runtime.GOOS == "windows" { 30 | // not supported by Windows 31 | return nil 32 | } 33 | return SyncFile(path) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.3.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | // +build !go1.4 17 | 18 | package goid 19 | 20 | // Get returns the id of the current goroutine. 21 | func Get() int64 22 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.3.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | // +build !go1.4 17 | 18 | #include 19 | 20 | void ·Get(int64 ret) { 21 | ret = g->goid; 22 | USED(&ret); 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/lstat_broken.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build linux android 8 | 9 | package osutil 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | "time" 15 | ) 16 | 17 | // Lstat is like os.Lstat, except lobotomized for Android. See 18 | // https://forum.syncthing.net/t/2395 19 | func Lstat(name string) (fi os.FileInfo, err error) { 20 | for i := 0; i < 10; i++ { // We have to draw the line somewhere 21 | fi, err = os.Lstat(name) 22 | if err, ok := err.(*os.PathError); ok && err.Err == syscall.EINTR { 23 | time.Sleep(time.Duration(i+1) * time.Millisecond) 24 | continue 25 | } 26 | return 27 | } 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/bpfopt_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import ( 8 | "os" 9 | "unsafe" 10 | 11 | "golang.org/x/net/bpf" 12 | "golang.org/x/net/internal/netreflect" 13 | ) 14 | 15 | // SetBPF attaches a BPF program to the connection. 16 | // 17 | // Only supported on Linux. 18 | func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { 19 | s, err := netreflect.PacketSocketOf(c.PacketConn) 20 | if err != nil { 21 | return err 22 | } 23 | prog := sockFProg{ 24 | Len: uint16(len(filter)), 25 | Filter: (*sockFilter)(unsafe.Pointer(&filter[0])), 26 | } 27 | return os.NewSyscallError("setsockopt", setsockopt(s, sysSOL_SOCKET, sysSO_ATTACH_FILTER, unsafe.Pointer(&prog), uint32(unsafe.Sizeof(prog)))) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/bpfopt_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import ( 8 | "os" 9 | "unsafe" 10 | 11 | "golang.org/x/net/bpf" 12 | "golang.org/x/net/internal/netreflect" 13 | ) 14 | 15 | // SetBPF attaches a BPF program to the connection. 16 | // 17 | // Only supported on Linux. 18 | func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { 19 | s, err := netreflect.PacketSocketOf(c.PacketConn) 20 | if err != nil { 21 | return err 22 | } 23 | prog := sockFProg{ 24 | Len: uint16(len(filter)), 25 | Filter: (*sockFilter)(unsafe.Pointer(&filter[0])), 26 | } 27 | return os.NewSyscallError("setsockopt", setsockopt(s, sysSOL_SOCKET, sysSO_ATTACH_FILTER, unsafe.Pointer(&prog), uint32(unsafe.Sizeof(prog)))) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/internal/netreflect/socket_posix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.9 6 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris windows 7 | 8 | package netreflect 9 | 10 | import ( 11 | "net" 12 | "reflect" 13 | "runtime" 14 | ) 15 | 16 | func socketOf(c net.Conn) (uintptr, error) { 17 | v := reflect.ValueOf(c) 18 | switch e := v.Elem(); e.Kind() { 19 | case reflect.Struct: 20 | fd := e.FieldByName("conn").FieldByName("fd") 21 | switch e := fd.Elem(); e.Kind() { 22 | case reflect.Struct: 23 | sysfd := e.FieldByName("sysfd") 24 | if runtime.GOOS == "windows" { 25 | return uintptr(sysfd.Uint()), nil 26 | } 27 | return uintptr(sysfd.Int()), nil 28 | } 29 | } 30 | return 0, errInvalidType 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/max.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "unicode/utf8" 6 | ) 7 | 8 | type Max struct { 9 | Limit int 10 | } 11 | 12 | func NewMax(l int) Max { 13 | return Max{l} 14 | } 15 | 16 | func (self Max) Match(s string) bool { 17 | var l int 18 | for range s { 19 | l += 1 20 | if l > self.Limit { 21 | return false 22 | } 23 | } 24 | 25 | return true 26 | } 27 | 28 | func (self Max) Index(s string) (int, []int) { 29 | segments := acquireSegments(self.Limit + 1) 30 | segments = append(segments, 0) 31 | var count int 32 | for i, r := range s { 33 | count++ 34 | if count > self.Limit { 35 | break 36 | } 37 | segments = append(segments, i+utf8.RuneLen(r)) 38 | } 39 | 40 | return 0, segments 41 | } 42 | 43 | func (self Max) Len() int { 44 | return lenNo 45 | } 46 | 47 | func (self Max) String() string { 48 | return fmt.Sprintf("", self.Limit) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/genericopt_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv4 8 | 9 | // TOS returns the type-of-service field value for outgoing packets. 10 | func (c *genericOpt) TOS() (int, error) { 11 | return 0, errOpNoSupport 12 | } 13 | 14 | // SetTOS sets the type-of-service field value for future outgoing 15 | // packets. 16 | func (c *genericOpt) SetTOS(tos int) error { 17 | return errOpNoSupport 18 | } 19 | 20 | // TTL returns the time-to-live field value for outgoing packets. 21 | func (c *genericOpt) TTL() (int, error) { 22 | return 0, errOpNoSupport 23 | } 24 | 25 | // SetTTL sets the time-to-live field value for future outgoing 26 | // packets. 27 | func (c *genericOpt) SetTTL(ttl int) error { 28 | return errOpNoSupport 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/syscall_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux,!386 netbsd openbsd 6 | 7 | package ipv4 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 15 | if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { 16 | return error(errno) 17 | } 18 | return nil 19 | } 20 | 21 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 22 | if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { 23 | return error(errno) 24 | } 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/syscall_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux,!386 netbsd openbsd 6 | 7 | package ipv6 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 15 | if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { 16 | return error(errno) 17 | } 18 | return nil 19 | } 20 | 21 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 22 | if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { 23 | return error(errno) 24 | } 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/single.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "github.com/gobwas/glob/util/runes" 6 | "unicode/utf8" 7 | ) 8 | 9 | // single represents ? 10 | type Single struct { 11 | Separators []rune 12 | } 13 | 14 | func NewSingle(s []rune) Single { 15 | return Single{s} 16 | } 17 | 18 | func (self Single) Match(s string) bool { 19 | r, w := utf8.DecodeRuneInString(s) 20 | if len(s) > w { 21 | return false 22 | } 23 | 24 | return runes.IndexRune(self.Separators, r) == -1 25 | } 26 | 27 | func (self Single) Len() int { 28 | return lenOne 29 | } 30 | 31 | func (self Single) Index(s string) (int, []int) { 32 | for i, r := range s { 33 | if runes.IndexRune(self.Separators, r) == -1 { 34 | return i, segmentsByRuneLength[utf8.RuneLen(r)] 35 | } 36 | } 37 | 38 | return -1, nil 39 | } 40 | 41 | func (self Single) String() string { 42 | return fmt.Sprintf("", string(self.Separators)) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/text.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "unicode/utf8" 7 | ) 8 | 9 | // raw represents raw string to match 10 | type Text struct { 11 | Str string 12 | RunesLength int 13 | BytesLength int 14 | Segments []int 15 | } 16 | 17 | func NewText(s string) Text { 18 | return Text{ 19 | Str: s, 20 | RunesLength: utf8.RuneCountInString(s), 21 | BytesLength: len(s), 22 | Segments: []int{len(s)}, 23 | } 24 | } 25 | 26 | func (self Text) Match(s string) bool { 27 | return self.Str == s 28 | } 29 | 30 | func (self Text) Len() int { 31 | return self.RunesLength 32 | } 33 | 34 | func (self Text) Index(s string) (int, []int) { 35 | index := strings.Index(s, self.Str) 36 | if index == -1 { 37 | return -1, nil 38 | } 39 | 40 | return index, self.Segments 41 | } 42 | 43 | func (self Text) String() string { 44 | return fmt.Sprintf("", self.Str) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/any.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "github.com/gobwas/glob/util/strings" 6 | ) 7 | 8 | type Any struct { 9 | Separators []rune 10 | } 11 | 12 | func NewAny(s []rune) Any { 13 | return Any{s} 14 | } 15 | 16 | func (self Any) Match(s string) bool { 17 | return strings.IndexAnyRunes(s, self.Separators) == -1 18 | } 19 | 20 | func (self Any) Index(s string) (int, []int) { 21 | found := strings.IndexAnyRunes(s, self.Separators) 22 | switch found { 23 | case -1: 24 | case 0: 25 | return 0, segments0 26 | default: 27 | s = s[:found] 28 | } 29 | 30 | segments := acquireSegments(len(s)) 31 | for i := range s { 32 | segments = append(segments, i) 33 | } 34 | segments = append(segments, len(s)) 35 | 36 | return 0, segments 37 | } 38 | 39 | func (self Any) Len() int { 40 | return lenNo 41 | } 42 | 43 | func (self Any) String() string { 44 | return fmt.Sprintf("", string(self.Separators)) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_slow.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | // +build go1.4,!go1.5,!amd64,!amd64p32,!arm,!386 go1.5,!go1.6,!amd64,!amd64p32,!arm go1.6,!amd64,!amd64p32,!arm 17 | 18 | package goid 19 | 20 | // Get returns the id of the current goroutine. 21 | func Get() int64 { 22 | return getSlow() 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.5plus.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | // Assembly to mimic runtime.getg. 17 | 18 | // +build amd64 amd64p32 19 | // +build go1.5 20 | 21 | #include "textflag.h" 22 | 23 | // func getg() uintptr 24 | TEXT ·getg(SB),NOSPLIT,$0-8 25 | MOVQ (TLS), BX 26 | MOVQ BX, ret+0(FP) 27 | RET 28 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/genericopt_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 6 | 7 | package ipv6 8 | 9 | // TrafficClass returns the traffic class field value for outgoing 10 | // packets. 11 | func (c *genericOpt) TrafficClass() (int, error) { 12 | return 0, errOpNoSupport 13 | } 14 | 15 | // SetTrafficClass sets the traffic class field value for future 16 | // outgoing packets. 17 | func (c *genericOpt) SetTrafficClass(tclass int) error { 18 | return errOpNoSupport 19 | } 20 | 21 | // HopLimit returns the hop limit field value for outgoing packets. 22 | func (c *genericOpt) HopLimit() (int, error) { 23 | return 0, errOpNoSupport 24 | } 25 | 26 | // SetHopLimit sets the hop limit field value for future outgoing 27 | // packets. 28 | func (c *genericOpt) SetHopLimit(hoplim int) error { 29 | return errOpNoSupport 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/syscall_linux_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | const ( 13 | sysGETSOCKOPT = 0xf 14 | sysSETSOCKOPT = 0xe 15 | ) 16 | 17 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) 18 | 19 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 20 | if _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { 21 | return error(errno) 22 | } 23 | return nil 24 | } 25 | 26 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 27 | if _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { 28 | return error(errno) 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/syscall_linux_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | const ( 13 | sysGETSOCKOPT = 0xf 14 | sysSETSOCKOPT = 0xe 15 | ) 16 | 17 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) 18 | 19 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 20 | if _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { 21 | return error(errno) 22 | } 23 | return nil 24 | } 25 | 26 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 27 | if _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { 28 | return error(errno) 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/range.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "unicode/utf8" 6 | ) 7 | 8 | type Range struct { 9 | Lo, Hi rune 10 | Not bool 11 | } 12 | 13 | func NewRange(lo, hi rune, not bool) Range { 14 | return Range{lo, hi, not} 15 | } 16 | 17 | func (self Range) Len() int { 18 | return lenOne 19 | } 20 | 21 | func (self Range) Match(s string) bool { 22 | r, w := utf8.DecodeRuneInString(s) 23 | if len(s) > w { 24 | return false 25 | } 26 | 27 | inRange := r >= self.Lo && r <= self.Hi 28 | 29 | return inRange == !self.Not 30 | } 31 | 32 | func (self Range) Index(s string) (int, []int) { 33 | for i, r := range s { 34 | if self.Not != (r >= self.Lo && r <= self.Hi) { 35 | return i, segmentsByRuneLength[utf8.RuneLen(r)] 36 | } 37 | } 38 | 39 | return -1, nil 40 | } 41 | 42 | func (self Range) String() string { 43 | var not string 44 | if self.Not { 45 | not = "!" 46 | } 47 | return fmt.Sprintf("", not, string(self.Lo), string(self.Hi)) 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/min.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "unicode/utf8" 6 | ) 7 | 8 | type Min struct { 9 | Limit int 10 | } 11 | 12 | func NewMin(l int) Min { 13 | return Min{l} 14 | } 15 | 16 | func (self Min) Match(s string) bool { 17 | var l int 18 | for range s { 19 | l += 1 20 | if l >= self.Limit { 21 | return true 22 | } 23 | } 24 | 25 | return false 26 | } 27 | 28 | func (self Min) Index(s string) (int, []int) { 29 | var count int 30 | 31 | c := len(s) - self.Limit + 1 32 | if c <= 0 { 33 | return -1, nil 34 | } 35 | 36 | segments := acquireSegments(c) 37 | for i, r := range s { 38 | count++ 39 | if count >= self.Limit { 40 | segments = append(segments, i+utf8.RuneLen(r)) 41 | } 42 | } 43 | 44 | if len(segments) == 0 { 45 | return -1, nil 46 | } 47 | 48 | return 0, segments 49 | } 50 | 51 | func (self Min) Len() int { 52 | return lenNo 53 | } 54 | 55 | func (self Min) String() string { 56 | return fmt.Sprintf("", self.Limit) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.5plus_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | // Assembly to mimic runtime.getg. 17 | // This should work on arm64 as well, but it hasn't been tested. 18 | 19 | // +build arm 20 | // +build go1.5 21 | 22 | #include "textflag.h" 23 | 24 | // func getg() uintptr 25 | TEXT ·getg(SB),NOSPLIT,$0-8 26 | MOVW g, ret+0(FP) 27 | RET 28 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/internal/netreflect/socket_19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.9 6 | 7 | package netreflect 8 | 9 | import ( 10 | "errors" 11 | "net" 12 | ) 13 | 14 | var ( 15 | errInvalidType = errors.New("invalid type") 16 | errOpNoSupport = errors.New("operation not supported") 17 | ) 18 | 19 | // SocketOf returns the socket descriptor of c. 20 | func SocketOf(c net.Conn) (uintptr, error) { 21 | switch c.(type) { 22 | case *net.TCPConn, *net.UDPConn, *net.IPConn, *net.UnixConn: 23 | return 0, errOpNoSupport 24 | default: 25 | return 0, errInvalidType 26 | } 27 | } 28 | 29 | // PacketSocketOf returns the socket descriptor of c. 30 | func PacketSocketOf(c net.PacketConn) (uintptr, error) { 31 | switch c.(type) { 32 | case *net.UDPConn, *net.IPConn, *net.UnixConn: 33 | return 0, errOpNoSupport 34 | default: 35 | return 0, errInvalidType 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/list.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "github.com/gobwas/glob/util/runes" 6 | "unicode/utf8" 7 | ) 8 | 9 | type List struct { 10 | List []rune 11 | Not bool 12 | } 13 | 14 | func NewList(list []rune, not bool) List { 15 | return List{list, not} 16 | } 17 | 18 | func (self List) Match(s string) bool { 19 | r, w := utf8.DecodeRuneInString(s) 20 | if len(s) > w { 21 | return false 22 | } 23 | 24 | inList := runes.IndexRune(self.List, r) != -1 25 | return inList == !self.Not 26 | } 27 | 28 | func (self List) Len() int { 29 | return lenOne 30 | } 31 | 32 | func (self List) Index(s string) (int, []int) { 33 | for i, r := range s { 34 | if self.Not == (runes.IndexRune(self.List, r) == -1) { 35 | return i, segmentsByRuneLength[utf8.RuneLen(r)] 36 | } 37 | } 38 | 39 | return -1, nil 40 | } 41 | 42 | func (self List) String() string { 43 | var not string 44 | if self.Not { 45 | not = "!" 46 | } 47 | 48 | return fmt.Sprintf("", not, string(self.List)) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_pledge.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build openbsd 6 | // +build 386 amd64 arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const ( 16 | SYS_PLEDGE = 108 17 | ) 18 | 19 | // Pledge implements the pledge syscall. For more information see pledge(2). 20 | func Pledge(promises string, paths []string) error { 21 | promisesPtr, err := syscall.BytePtrFromString(promises) 22 | if err != nil { 23 | return err 24 | } 25 | promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) 26 | if paths != nil { 27 | var pathsPtr []*byte 28 | if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { 29 | return err 30 | } 31 | pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) 32 | } 33 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) 34 | if e != 0 { 35 | return e 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/debug_debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // +build debug 6 | 7 | package notify 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "runtime" 13 | "strings" 14 | ) 15 | 16 | func dbgprint(v ...interface{}) { 17 | fmt.Printf("[D] ") 18 | fmt.Print(v...) 19 | fmt.Printf("\n\n") 20 | } 21 | 22 | func dbgprintf(format string, v ...interface{}) { 23 | fmt.Printf("[D] ") 24 | fmt.Printf(format, v...) 25 | fmt.Printf("\n\n") 26 | } 27 | 28 | func dbgcallstack(max int) []string { 29 | pc, stack := make([]uintptr, max), make([]string, 0, max) 30 | runtime.Callers(2, pc) 31 | for _, pc := range pc { 32 | if f := runtime.FuncForPC(pc); f != nil { 33 | fname := f.Name() 34 | idx := strings.LastIndex(fname, string(os.PathSeparator)) 35 | if idx != -1 { 36 | stack = append(stack, fname[idx+1:]) 37 | } else { 38 | stack = append(stack, fname) 39 | } 40 | } 41 | } 42 | return stack 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/prefix.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "unicode/utf8" 7 | ) 8 | 9 | type Prefix struct { 10 | Prefix string 11 | } 12 | 13 | func NewPrefix(p string) Prefix { 14 | return Prefix{p} 15 | } 16 | 17 | func (self Prefix) Index(s string) (int, []int) { 18 | idx := strings.Index(s, self.Prefix) 19 | if idx == -1 { 20 | return -1, nil 21 | } 22 | 23 | length := len(self.Prefix) 24 | var sub string 25 | if len(s) > idx+length { 26 | sub = s[idx+length:] 27 | } else { 28 | sub = "" 29 | } 30 | 31 | segments := acquireSegments(len(sub) + 1) 32 | segments = append(segments, length) 33 | for i, r := range sub { 34 | segments = append(segments, length+i+utf8.RuneLen(r)) 35 | } 36 | 37 | return idx, segments 38 | } 39 | 40 | func (self Prefix) Len() int { 41 | return lenNo 42 | } 43 | 44 | func (self Prefix) Match(s string) bool { 45 | return strings.HasPrefix(s, self.Prefix) 46 | } 47 | 48 | func (self Prefix) String() string { 49 | return fmt.Sprintf("", self.Prefix) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/event_stub.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows 6 | // +build !kqueue,!solaris 7 | 8 | package notify 9 | 10 | // Platform independent event values. 11 | const ( 12 | osSpecificCreate Event = 1 << iota 13 | osSpecificRemove 14 | osSpecificWrite 15 | osSpecificRename 16 | // internal 17 | // recursive is used to distinguish recursive eventsets from non-recursive ones 18 | recursive 19 | // omit is used for dispatching internal events; only those events are sent 20 | // for which both the event and the watchpoint has omit in theirs event sets. 21 | omit 22 | ) 23 | 24 | var osestr = map[Event]string{} 25 | 26 | type event struct{} 27 | 28 | func (e *event) Event() (_ Event) { return } 29 | func (e *event) Path() (_ string) { return } 30 | func (e *event) Sys() (_ interface{}) { return } 31 | func (e *event) isDir() (_ bool, _ error) { return } 32 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/control_pktinfo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin linux solaris 6 | 7 | package ipv4 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | 13 | "golang.org/x/net/internal/iana" 14 | ) 15 | 16 | func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { 17 | m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 18 | m.Level = iana.ProtocolIP 19 | m.Type = sysIP_PKTINFO 20 | m.SetLen(syscall.CmsgLen(sizeofInetPktinfo)) 21 | if cm != nil { 22 | pi := (*inetPktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) 23 | if ip := cm.Src.To4(); ip != nil { 24 | copy(pi.Spec_dst[:], ip) 25 | } 26 | if cm.IfIndex > 0 { 27 | pi.setIfindex(cm.IfIndex) 28 | } 29 | } 30 | return b[syscall.CmsgSpace(sizeofInetPktinfo):] 31 | } 32 | 33 | func parsePacketInfo(cm *ControlMessage, b []byte) { 34 | pi := (*inetPktinfo)(unsafe.Pointer(&b[0])) 35 | cm.IfIndex = int(pi.Ifindex) 36 | cm.Dst = pi.Addr[:] 37 | } 38 | -------------------------------------------------------------------------------- /cross-compile-xgo.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | targets = "darwin/amd64, 4 | dragonfly/amd64, 5 | freebsd/*, 6 | linux/*, 7 | netbsd/*, 8 | openbsd/*, 9 | windows/*" 10 | 11 | targets.gsub!(" ","").gsub!("\n","") 12 | 13 | version = `git describe --abbrev=0 --tags`.chomp 14 | diff = `git diff`.chomp 15 | 16 | #unless diff.empty? 17 | # puts "Forgot to git reset --hard?" 18 | # exit if gets.chomp != "n" 19 | #end 20 | 21 | vars = "GO386=387" 22 | ldflags = "-w -X main.Version=#{version}" 23 | build = "#{vars} xgo -v --targets=#{targets} -ldflags '#{ldflags}' ." 24 | puts "Running #{build}" 25 | #`#{build}` 26 | 27 | Dir.glob("syncthing-inotify-*").each do |file| 28 | next unless File.file?(file) 29 | next if file.include?(".tar.gz") 30 | name = "syncthing-inotify" 31 | if file.include?("windows") 32 | name = "syncthing-inotify.exe" 33 | end 34 | move = "cp #{file} #{name}" 35 | package = "tar -czf #{file}-#{version}.tar.gz #{name}" 36 | rm = "rm -f syncthing-inotify" 37 | #rm = "rm -f syncthing-inotify #{name}" 38 | puts "Packaging #{file}" 39 | `#{move} && #{package} 40 | & #{rm}` 41 | end 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/defs_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // +godefs map struct_in_addr [4]byte /* in_addr */ 8 | 9 | package ipv4 10 | 11 | /* 12 | #include 13 | */ 14 | import "C" 15 | 16 | const ( 17 | sysIP_OPTIONS = C.IP_OPTIONS 18 | sysIP_HDRINCL = C.IP_HDRINCL 19 | sysIP_TOS = C.IP_TOS 20 | sysIP_TTL = C.IP_TTL 21 | sysIP_RECVOPTS = C.IP_RECVOPTS 22 | sysIP_RECVRETOPTS = C.IP_RECVRETOPTS 23 | sysIP_RECVDSTADDR = C.IP_RECVDSTADDR 24 | sysIP_RETOPTS = C.IP_RETOPTS 25 | sysIP_RECVIF = C.IP_RECVIF 26 | sysIP_RECVTTL = C.IP_RECVTTL 27 | 28 | sysIP_MULTICAST_IF = C.IP_MULTICAST_IF 29 | sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL 30 | sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP 31 | sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP 32 | sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP 33 | 34 | sizeofIPMreq = C.sizeof_struct_ip_mreq 35 | ) 36 | 37 | type ipMreq C.struct_ip_mreq 38 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/defs_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // +godefs map struct_in_addr [4]byte /* in_addr */ 8 | 9 | package ipv4 10 | 11 | /* 12 | #include 13 | */ 14 | import "C" 15 | 16 | const ( 17 | sysIP_OPTIONS = C.IP_OPTIONS 18 | sysIP_HDRINCL = C.IP_HDRINCL 19 | sysIP_TOS = C.IP_TOS 20 | sysIP_TTL = C.IP_TTL 21 | sysIP_RECVOPTS = C.IP_RECVOPTS 22 | sysIP_RECVRETOPTS = C.IP_RECVRETOPTS 23 | sysIP_RECVDSTADDR = C.IP_RECVDSTADDR 24 | sysIP_RETOPTS = C.IP_RETOPTS 25 | sysIP_RECVIF = C.IP_RECVIF 26 | sysIP_RECVTTL = C.IP_RECVTTL 27 | 28 | sysIP_MULTICAST_IF = C.IP_MULTICAST_IF 29 | sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL 30 | sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP 31 | sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP 32 | sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP 33 | 34 | sizeofIPMreq = C.sizeof_struct_ip_mreq 35 | ) 36 | 37 | type ipMreq C.struct_ip_mreq 38 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/replacingwriter.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "bytes" 11 | "io" 12 | ) 13 | 14 | type ReplacingWriter struct { 15 | Writer io.Writer 16 | From byte 17 | To []byte 18 | } 19 | 20 | func (w ReplacingWriter) Write(bs []byte) (int, error) { 21 | var n, written int 22 | var err error 23 | 24 | newlineIdx := bytes.IndexByte(bs, w.From) 25 | for newlineIdx >= 0 { 26 | n, err = w.Writer.Write(bs[:newlineIdx]) 27 | written += n 28 | if err != nil { 29 | break 30 | } 31 | if len(w.To) > 0 { 32 | n, err := w.Writer.Write(w.To) 33 | if n == len(w.To) { 34 | written++ 35 | } 36 | if err != nil { 37 | break 38 | } 39 | } 40 | bs = bs[newlineIdx+1:] 41 | newlineIdx = bytes.IndexByte(bs, w.From) 42 | } 43 | 44 | n, err = w.Writer.Write(bs) 45 | written += n 46 | 47 | return written, err 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/cmd/globdraw/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "github.com/gobwas/glob" 7 | "github.com/gobwas/glob/match" 8 | "github.com/gobwas/glob/match/debug" 9 | "os" 10 | "strings" 11 | "unicode/utf8" 12 | ) 13 | 14 | func main() { 15 | pattern := flag.String("p", "", "pattern to draw") 16 | sep := flag.String("s", "", "comma separated list of separators characters") 17 | flag.Parse() 18 | 19 | if *pattern == "" { 20 | flag.Usage() 21 | os.Exit(1) 22 | } 23 | 24 | var separators []rune 25 | if len(*sep) > 0 { 26 | for _, c := range strings.Split(*sep, ",") { 27 | if r, w := utf8.DecodeRuneInString(c); len(c) > w { 28 | fmt.Println("only single charactered separators are allowed") 29 | os.Exit(1) 30 | } else { 31 | separators = append(separators, r) 32 | } 33 | } 34 | } 35 | 36 | glob, err := glob.Compile(*pattern, separators...) 37 | if err != nil { 38 | fmt.Println("could not compile pattern:", err) 39 | os.Exit(1) 40 | } 41 | 42 | matcher := glob.(match.Matcher) 43 | fmt.Fprint(os.Stdout, debug.Graphviz(*pattern, matcher)) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/cenkalti/backoff/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Cenk Altı 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 The Notify Authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/ping.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "net/url" 11 | "time" 12 | 13 | "github.com/syncthing/syncthing/lib/dialer" 14 | ) 15 | 16 | // TCPPing returns the duration required to establish a TCP connection 17 | // to the given host. ICMP packets require root privileges, hence why we use 18 | // tcp. 19 | func TCPPing(address string) (time.Duration, error) { 20 | start := time.Now() 21 | conn, err := dialer.DialTimeout("tcp", address, time.Second) 22 | if conn != nil { 23 | conn.Close() 24 | } 25 | return time.Since(start), err 26 | } 27 | 28 | // GetLatencyForURL parses the given URL, tries opening a TCP connection to it 29 | // and returns the time it took to establish the connection. 30 | func GetLatencyForURL(addr string) (time.Duration, error) { 31 | uri, err := url.Parse(addr) 32 | if err != nil { 33 | return 0, err 34 | } 35 | 36 | return TCPPing(uri.Host) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/defs_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // +godefs map struct_in_addr [4]byte /* in_addr */ 8 | 9 | package ipv4 10 | 11 | /* 12 | #include 13 | */ 14 | import "C" 15 | 16 | const ( 17 | sysIP_OPTIONS = C.IP_OPTIONS 18 | sysIP_HDRINCL = C.IP_HDRINCL 19 | sysIP_TOS = C.IP_TOS 20 | sysIP_TTL = C.IP_TTL 21 | sysIP_RECVOPTS = C.IP_RECVOPTS 22 | sysIP_RECVRETOPTS = C.IP_RECVRETOPTS 23 | sysIP_RECVDSTADDR = C.IP_RECVDSTADDR 24 | sysIP_RETOPTS = C.IP_RETOPTS 25 | sysIP_RECVIF = C.IP_RECVIF 26 | sysIP_RECVTTL = C.IP_RECVTTL 27 | 28 | sysIP_MULTICAST_IF = C.IP_MULTICAST_IF 29 | sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL 30 | sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP 31 | sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF 32 | sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP 33 | sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP 34 | 35 | sizeofIPMreq = C.sizeof_struct_ip_mreq 36 | ) 37 | 38 | type ipMreq C.struct_ip_mreq 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/internal/netreflect/socket.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.9 6 | 7 | // Package netreflect implements run-time reflection for the 8 | // facilities of net package. 9 | // 10 | // This package works only for Go 1.8 or below. 11 | package netreflect 12 | 13 | import ( 14 | "errors" 15 | "net" 16 | ) 17 | 18 | var ( 19 | errInvalidType = errors.New("invalid type") 20 | errOpNoSupport = errors.New("operation not supported") 21 | ) 22 | 23 | // SocketOf returns the socket descriptor of c. 24 | func SocketOf(c net.Conn) (uintptr, error) { 25 | switch c.(type) { 26 | case *net.TCPConn, *net.UDPConn, *net.IPConn, *net.UnixConn: 27 | return socketOf(c) 28 | default: 29 | return 0, errInvalidType 30 | } 31 | } 32 | 33 | // PacketSocketOf returns the socket descriptor of c. 34 | func PacketSocketOf(c net.PacketConn) (uintptr, error) { 35 | switch c.(type) { 36 | case *net.UDPConn, *net.IPConn, *net.UnixConn: 37 | return socketOf(c.(net.Conn)) 38 | default: 39 | return 0, errInvalidType 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | package goid 17 | 18 | import ( 19 | "bytes" 20 | "runtime" 21 | "strconv" 22 | ) 23 | 24 | func ExtractGID(s []byte) int64 { 25 | s = s[len("goroutine "):] 26 | s = s[:bytes.IndexByte(s, ' ')] 27 | gid, _ := strconv.ParseInt(string(s), 10, 64) 28 | return gid 29 | } 30 | 31 | // Parse the goid from runtime.Stack() output. Slow, but it works. 32 | func getSlow() int64 { 33 | var buf [64]byte 34 | return ExtractGID(buf[:runtime.Stack(buf[:], false)]) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/contains.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type Contains struct { 9 | Needle string 10 | Not bool 11 | } 12 | 13 | func NewContains(needle string, not bool) Contains { 14 | return Contains{needle, not} 15 | } 16 | 17 | func (self Contains) Match(s string) bool { 18 | return strings.Contains(s, self.Needle) != self.Not 19 | } 20 | 21 | func (self Contains) Index(s string) (int, []int) { 22 | var offset int 23 | 24 | idx := strings.Index(s, self.Needle) 25 | 26 | if !self.Not { 27 | if idx == -1 { 28 | return -1, nil 29 | } 30 | 31 | offset = idx + len(self.Needle) 32 | if len(s) <= offset { 33 | return 0, []int{offset} 34 | } 35 | s = s[offset:] 36 | } else if idx != -1 { 37 | s = s[:idx] 38 | } 39 | 40 | segments := acquireSegments(len(s) + 1) 41 | for i := range s { 42 | segments = append(segments, offset+i) 43 | } 44 | 45 | return 0, append(segments, offset+len(s)) 46 | } 47 | 48 | func (self Contains) Len() int { 49 | return lenNo 50 | } 51 | 52 | func (self Contains) String() string { 53 | var not string 54 | if self.Not { 55 | not = "!" 56 | } 57 | return fmt.Sprintf("", not, self.Needle) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/fsroots_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package osutil 10 | 11 | import ( 12 | "bytes" 13 | "fmt" 14 | "syscall" 15 | "unsafe" 16 | ) 17 | 18 | func GetFilesystemRoots() ([]string, error) { 19 | kernel32, err := syscall.LoadDLL("kernel32.dll") 20 | if err != nil { 21 | return nil, err 22 | } 23 | getLogicalDriveStringsHandle, err := kernel32.FindProc("GetLogicalDriveStringsA") 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | buffer := [1024]byte{} 29 | bufferSize := uint32(len(buffer)) 30 | 31 | hr, _, _ := getLogicalDriveStringsHandle.Call(uintptr(unsafe.Pointer(&bufferSize)), uintptr(unsafe.Pointer(&buffer))) 32 | if hr == 0 { 33 | return nil, fmt.Errorf("Syscall failed") 34 | } 35 | 36 | var drives []string 37 | parts := bytes.Split(buffer[:], []byte{0}) 38 | for _, part := range parts { 39 | if len(part) == 0 { 40 | break 41 | } 42 | drives = append(drives, string(part)) 43 | } 44 | 45 | return drives, nil 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/control_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package ipv4 8 | 9 | import ( 10 | "net" 11 | "syscall" 12 | "unsafe" 13 | 14 | "golang.org/x/net/internal/iana" 15 | ) 16 | 17 | func marshalDst(b []byte, cm *ControlMessage) []byte { 18 | m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 19 | m.Level = iana.ProtocolIP 20 | m.Type = sysIP_RECVDSTADDR 21 | m.SetLen(syscall.CmsgLen(net.IPv4len)) 22 | return b[syscall.CmsgSpace(net.IPv4len):] 23 | } 24 | 25 | func parseDst(cm *ControlMessage, b []byte) { 26 | cm.Dst = b[:net.IPv4len] 27 | } 28 | 29 | func marshalInterface(b []byte, cm *ControlMessage) []byte { 30 | m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 31 | m.Level = iana.ProtocolIP 32 | m.Type = sysIP_RECVIF 33 | m.SetLen(syscall.CmsgLen(syscall.SizeofSockaddrDatalink)) 34 | return b[syscall.CmsgSpace(syscall.SizeofSockaddrDatalink):] 35 | } 36 | 37 | func parseInterface(cm *ControlMessage, b []byte) { 38 | sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0])) 39 | cm.IfIndex = int(sadl.Index) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.6plus.go: -------------------------------------------------------------------------------- 1 | // +build amd64 amd64p32 arm 2 | // +build go1.6 3 | 4 | package goid 5 | 6 | import "unsafe" 7 | 8 | // Just enough of the structs from runtime/runtime2.go to get the offset to goid. 9 | // See https://github.com/golang/go/blob/release-branch.go1.6/src/runtime/runtime2.go 10 | 11 | type stack struct { 12 | lo uintptr 13 | hi uintptr 14 | } 15 | 16 | type gobuf struct { 17 | sp uintptr 18 | pc uintptr 19 | g uintptr 20 | ctxt uintptr 21 | ret uintptr 22 | lr uintptr 23 | bp uintptr 24 | } 25 | 26 | type g struct { 27 | stack stack 28 | stackguard0 uintptr 29 | stackguard1 uintptr 30 | 31 | _panic uintptr 32 | _defer uintptr 33 | m uintptr 34 | stackAlloc uintptr 35 | sched gobuf 36 | syscallsp uintptr 37 | syscallpc uintptr 38 | stkbar []uintptr 39 | stkbarPos uintptr 40 | stktopsp uintptr 41 | param unsafe.Pointer 42 | atomicstatus uint32 43 | stackLock uint32 44 | goid int64 // Here it is! 45 | } 46 | 47 | // Backdoor access to runtime·getg(). 48 | func getg() uintptr // in goid_go1.5plus{,_arm}.s 49 | 50 | func Get() int64 { 51 | gg := (*g)(unsafe.Pointer(getg())) 52 | return gg.goid 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin freebsd linux 6 | 7 | package ipv4 8 | 9 | import ( 10 | "net" 11 | "os" 12 | "unsafe" 13 | 14 | "golang.org/x/net/internal/iana" 15 | ) 16 | 17 | func getsockoptIPMreqn(s uintptr, name int) (*net.Interface, error) { 18 | var mreqn ipMreqn 19 | l := uint32(sizeofIPMreqn) 20 | if err := getsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), &l); err != nil { 21 | return nil, os.NewSyscallError("getsockopt", err) 22 | } 23 | if mreqn.Ifindex == 0 { 24 | return nil, nil 25 | } 26 | ifi, err := net.InterfaceByIndex(int(mreqn.Ifindex)) 27 | if err != nil { 28 | return nil, err 29 | } 30 | return ifi, nil 31 | } 32 | 33 | func setsockoptIPMreqn(s uintptr, name int, ifi *net.Interface, grp net.IP) error { 34 | var mreqn ipMreqn 35 | if ifi != nil { 36 | mreqn.Ifindex = int32(ifi.Index) 37 | } 38 | if grp != nil { 39 | mreqn.Multiaddr = [4]byte{grp[0], grp[1], grp[2], grp[3]} 40 | } 41 | return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), sizeofIPMreqn)) 42 | } 43 | -------------------------------------------------------------------------------- /etc/macosx-launchd/syncthing-inotify.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | Label 12 | net.syncthing.syncthing-inotify 13 | 14 | ProgramArguments 15 | 16 | /Users/USERNAME/bin/syncthing-inotify 17 | 18 | 19 | EnvironmentVariables 20 | 21 | HOME 22 | /Users/USERNAME 23 | 24 | 25 | KeepAlive 26 | 27 | 28 | LowPriorityIO 29 | 30 | 31 | ProcessType 32 | Background 33 | 34 | StandardOutPath 35 | /Users/USERNAME/Library/Logs/Syncthing-inotify.log 36 | 37 | StandardErrorPath 38 | /Users/USERNAME/Library/Logs/Syncthing-inotify-errors.log 39 | 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sys_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import ( 8 | "net" 9 | "syscall" 10 | ) 11 | 12 | var ( 13 | ctlOpts = [ctlMax]ctlOpt{ 14 | ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, 15 | ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, 16 | ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, 17 | } 18 | 19 | sockOpts = [ssoMax]sockOpt{ 20 | ssoTOS: {sysIP_TOS, ssoTypeInt}, 21 | ssoTTL: {sysIP_TTL, ssoTypeInt}, 22 | ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, 23 | ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, 24 | ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeByte}, 25 | ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, 26 | ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, 27 | ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, 28 | ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, 29 | ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, 30 | ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, 31 | } 32 | ) 33 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/helper.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import ( 8 | "encoding/binary" 9 | "errors" 10 | "net" 11 | "unsafe" 12 | ) 13 | 14 | var ( 15 | errMissingAddress = errors.New("missing address") 16 | errHeaderTooShort = errors.New("header too short") 17 | errInvalidConnType = errors.New("invalid conn type") 18 | errOpNoSupport = errors.New("operation not supported") 19 | errNoSuchInterface = errors.New("no such interface") 20 | 21 | nativeEndian binary.ByteOrder 22 | ) 23 | 24 | func init() { 25 | i := uint32(1) 26 | b := (*[4]byte)(unsafe.Pointer(&i)) 27 | if b[0] == 1 { 28 | nativeEndian = binary.LittleEndian 29 | } else { 30 | nativeEndian = binary.BigEndian 31 | } 32 | } 33 | 34 | func boolint(b bool) int { 35 | if b { 36 | return 1 37 | } 38 | return 0 39 | } 40 | 41 | func netAddrToIP16(a net.Addr) net.IP { 42 | switch v := a.(type) { 43 | case *net.UDPAddr: 44 | if ip := v.IP.To16(); ip != nil && ip.To4() == nil { 45 | return ip 46 | } 47 | case *net.IPAddr: 48 | if ip := v.IP.To16(); ip != nil && ip.To4() == nil { 49 | return ip 50 | } 51 | } 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/syntax/ast/ast.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | type Node struct { 4 | Parent *Node 5 | Children []*Node 6 | Value interface{} 7 | Kind Kind 8 | } 9 | 10 | func NewNode(k Kind, v interface{}, ch ...*Node) *Node { 11 | n := &Node{ 12 | Kind: k, 13 | Value: v, 14 | } 15 | for _, c := range ch { 16 | Insert(n, c) 17 | } 18 | return n 19 | } 20 | 21 | func (a *Node) Equal(b *Node) bool { 22 | if a.Kind != b.Kind { 23 | return false 24 | } 25 | if a.Value != b.Value { 26 | return false 27 | } 28 | if len(a.Children) != len(b.Children) { 29 | return false 30 | } 31 | for i, c := range a.Children { 32 | if !c.Equal(b.Children[i]) { 33 | return false 34 | } 35 | } 36 | return true 37 | } 38 | 39 | func Insert(parent *Node, children ...*Node) { 40 | parent.Children = append(parent.Children, children...) 41 | for _, ch := range children { 42 | ch.Parent = parent 43 | } 44 | } 45 | 46 | type List struct { 47 | Not bool 48 | Chars string 49 | } 50 | 51 | type Range struct { 52 | Not bool 53 | Lo, Hi rune 54 | } 55 | 56 | type Text struct { 57 | Text string 58 | } 59 | 60 | type Kind int 61 | 62 | const ( 63 | KindNothing Kind = iota 64 | KindPattern 65 | KindList 66 | KindRange 67 | KindText 68 | KindAny 69 | KindSuper 70 | KindSingle 71 | KindAnyOf 72 | ) 73 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | // +build go1.4,!go1.5 17 | 18 | package goid 19 | 20 | import "unsafe" 21 | 22 | var pointerSize = unsafe.Sizeof(uintptr(0)) 23 | 24 | // Backdoor access to runtime·getg(). 25 | func getg() uintptr // in goid_go1.4.s 26 | 27 | // Get returns the id of the current goroutine. 28 | func Get() int64 { 29 | // The goid is the 16th field in the G struct where each field is a 30 | // pointer, uintptr or padded to that size. See runtime.h from the 31 | // Go sources. I'm not aware of a cleaner way to determine the 32 | // offset. 33 | return *(*int64)(unsafe.Pointer(getg() + 16*pointerSize)) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sys_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly netbsd 6 | 7 | package ipv4 8 | 9 | import ( 10 | "net" 11 | "syscall" 12 | ) 13 | 14 | var ( 15 | ctlOpts = [ctlMax]ctlOpt{ 16 | ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, 17 | ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, 18 | ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, 19 | } 20 | 21 | sockOpts = [ssoMax]sockOpt{ 22 | ssoTOS: {sysIP_TOS, ssoTypeInt}, 23 | ssoTTL: {sysIP_TTL, ssoTypeInt}, 24 | ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, 25 | ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, 26 | ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, 27 | ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, 28 | ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, 29 | ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, 30 | ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, 31 | ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, 32 | ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, 33 | } 34 | ) 35 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/syscall_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | //go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so" 13 | //go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" 14 | 15 | //go:linkname procGetsockopt libc___xnet_getsockopt 16 | //go:linkname procSetsockopt libc_setsockopt 17 | 18 | var ( 19 | procGetsockopt uintptr 20 | procSetsockopt uintptr 21 | ) 22 | 23 | func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) 24 | 25 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 26 | _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procGetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0) 27 | if errno != 0 { 28 | return error(errno) 29 | } 30 | return nil 31 | } 32 | 33 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 34 | if _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procSetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { 35 | return error(errno) 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/syscall_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | //go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so" 13 | //go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" 14 | 15 | //go:linkname procGetsockopt libc___xnet_getsockopt 16 | //go:linkname procSetsockopt libc_setsockopt 17 | 18 | var ( 19 | procGetsockopt uintptr 20 | procSetsockopt uintptr 21 | ) 22 | 23 | func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) 24 | 25 | func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { 26 | _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procGetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0) 27 | if errno != 0 { 28 | return error(errno) 29 | } 30 | return nil 31 | } 32 | 33 | func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { 34 | if _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procSetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { 35 | return error(errno) 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/iana.go: -------------------------------------------------------------------------------- 1 | // go generate gen.go 2 | // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT 3 | 4 | package ipv4 5 | 6 | // Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19 7 | const ( 8 | ICMPTypeEchoReply ICMPType = 0 // Echo Reply 9 | ICMPTypeDestinationUnreachable ICMPType = 3 // Destination Unreachable 10 | ICMPTypeRedirect ICMPType = 5 // Redirect 11 | ICMPTypeEcho ICMPType = 8 // Echo 12 | ICMPTypeRouterAdvertisement ICMPType = 9 // Router Advertisement 13 | ICMPTypeRouterSolicitation ICMPType = 10 // Router Solicitation 14 | ICMPTypeTimeExceeded ICMPType = 11 // Time Exceeded 15 | ICMPTypeParameterProblem ICMPType = 12 // Parameter Problem 16 | ICMPTypeTimestamp ICMPType = 13 // Timestamp 17 | ICMPTypeTimestampReply ICMPType = 14 // Timestamp Reply 18 | ICMPTypePhoturis ICMPType = 40 // Photuris 19 | ) 20 | 21 | // Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19 22 | var icmpTypes = map[ICMPType]string{ 23 | 0: "echo reply", 24 | 3: "destination unreachable", 25 | 5: "redirect", 26 | 8: "echo", 27 | 9: "router advertisement", 28 | 10: "router solicitation", 29 | 11: "time exceeded", 30 | 12: "parameter problem", 31 | 13: "timestamp", 32 | 14: "timestamp reply", 33 | 40: "photuris", 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/zillode/notify/watchpoint_readdcw.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package notify 8 | 9 | // eventmask uses ei to create a new event which contains internal flags used by 10 | // notify package logic. If one of FileAction* masks is detected, this function 11 | // adds corresponding FileNotifyChange* values. This allows non registered 12 | // FileAction* events to be passed on. 13 | func eventmask(ei EventInfo, extra Event) (e Event) { 14 | if e = ei.Event() | extra; e&fileActionAll != 0 { 15 | if ev, ok := ei.(*event); ok { 16 | switch ev.ftype { 17 | case fTypeFile: 18 | e |= FileNotifyChangeFileName 19 | case fTypeDirectory: 20 | e |= FileNotifyChangeDirName 21 | case fTypeUnknown: 22 | e |= fileNotifyChangeModified 23 | } 24 | return e &^ fileActionAll 25 | } 26 | } 27 | return 28 | } 29 | 30 | // matches reports a match only when: 31 | // 32 | // - for user events, when event is present in the given set 33 | // - for internal events, when additionally both event and set have omit bit set 34 | // 35 | // Internal events must not be sent to user channels and vice versa. 36 | func matches(set, event Event) bool { 37 | return (set&omit)^(event&omit) == 0 && (set&event == event || set&fileNotifyChangeModified&event != 0) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/syntax/lexer/token.go: -------------------------------------------------------------------------------- 1 | package lexer 2 | 3 | import "fmt" 4 | 5 | type TokenType int 6 | 7 | const ( 8 | EOF TokenType = iota 9 | Error 10 | Text 11 | Char 12 | Any 13 | Super 14 | Single 15 | Not 16 | Separator 17 | RangeOpen 18 | RangeClose 19 | RangeLo 20 | RangeHi 21 | RangeBetween 22 | TermsOpen 23 | TermsClose 24 | ) 25 | 26 | func (tt TokenType) String() string { 27 | switch tt { 28 | case EOF: 29 | return "eof" 30 | 31 | case Error: 32 | return "error" 33 | 34 | case Text: 35 | return "text" 36 | 37 | case Char: 38 | return "char" 39 | 40 | case Any: 41 | return "any" 42 | 43 | case Super: 44 | return "super" 45 | 46 | case Single: 47 | return "single" 48 | 49 | case Not: 50 | return "not" 51 | 52 | case Separator: 53 | return "separator" 54 | 55 | case RangeOpen: 56 | return "range_open" 57 | 58 | case RangeClose: 59 | return "range_close" 60 | 61 | case RangeLo: 62 | return "range_lo" 63 | 64 | case RangeHi: 65 | return "range_hi" 66 | 67 | case RangeBetween: 68 | return "range_between" 69 | 70 | case TermsOpen: 71 | return "terms_open" 72 | 73 | case TermsClose: 74 | return "terms_close" 75 | 76 | default: 77 | return "undef" 78 | } 79 | } 80 | 81 | type Token struct { 82 | Type TokenType 83 | Raw string 84 | } 85 | 86 | func (t Token) String() string { 87 | return fmt.Sprintf("%v<%q>", t.Type, t.Raw) 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/hidden_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package osutil 10 | 11 | import "syscall" 12 | 13 | func HideFile(path string) error { 14 | p, err := syscall.UTF16PtrFromString(path) 15 | if err != nil { 16 | return err 17 | } 18 | 19 | attrs, err := syscall.GetFileAttributes(p) 20 | if err != nil { 21 | return err 22 | } 23 | 24 | attrs |= syscall.FILE_ATTRIBUTE_HIDDEN 25 | return syscall.SetFileAttributes(p, attrs) 26 | } 27 | 28 | func ShowFile(path string) error { 29 | p, err := syscall.UTF16PtrFromString(path) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | attrs, err := syscall.GetFileAttributes(p) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | attrs &^= syscall.FILE_ATTRIBUTE_HIDDEN 40 | return syscall.SetFileAttributes(p, attrs) 41 | } 42 | 43 | func HideConsole() { 44 | getConsoleWindow := syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow") 45 | showWindow := syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow") 46 | if getConsoleWindow.Find() == nil && showWindow.Find() == nil { 47 | hwnd, _, _ := getConsoleWindow.Call() 48 | if hwnd != 0 { 49 | showWindow.Call(hwnd, 0) 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/sync/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package sync 8 | 9 | import ( 10 | "os" 11 | "strconv" 12 | "strings" 13 | "time" 14 | 15 | "github.com/sasha-s/go-deadlock" 16 | "github.com/syncthing/syncthing/lib/logger" 17 | ) 18 | 19 | var ( 20 | threshold = 100 * time.Millisecond 21 | l = logger.DefaultLogger.NewFacility("sync", "Mutexes") 22 | 23 | // We make an exception in this package and have an actual "if debug { ... 24 | // }" variable, as it may be rather performance critical and does 25 | // nonstandard things (from a debug logging PoV). 26 | debug = strings.Contains(os.Getenv("STTRACE"), "sync") || os.Getenv("STTRACE") == "all" 27 | useDeadlock = os.Getenv("STDEADLOCK") != "" 28 | ) 29 | 30 | func init() { 31 | l.SetDebug("sync", strings.Contains(os.Getenv("STTRACE"), "sync") || os.Getenv("STTRACE") == "all") 32 | 33 | if n, err := strconv.Atoi(os.Getenv("STLOCKTHRESHOLD")); err == nil { 34 | threshold = time.Duration(n) * time.Millisecond 35 | } 36 | if n, err := strconv.Atoi(os.Getenv("STDEADLOCK")); err == nil { 37 | deadlock.Opts.DeadlockTimeout = time.Duration(n) * time.Second 38 | } 39 | l.Debugf("Enabling lock logging at %v threshold", threshold) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/cenkalti/backoff/retry.go: -------------------------------------------------------------------------------- 1 | package backoff 2 | 3 | import "time" 4 | 5 | // An Operation is executing by Retry() or RetryNotify(). 6 | // The operation will be retried using a backoff policy if it returns an error. 7 | type Operation func() error 8 | 9 | // Notify is a notify-on-error function. It receives an operation error and 10 | // backoff delay if the operation failed (with an error). 11 | // 12 | // NOTE that if the backoff policy stated to stop retrying, 13 | // the notify function isn't called. 14 | type Notify func(error, time.Duration) 15 | 16 | // Retry the operation o until it does not return error or BackOff stops. 17 | // o is guaranteed to be run at least once. 18 | // It is the caller's responsibility to reset b after Retry returns. 19 | // 20 | // Retry sleeps the goroutine for the duration returned by BackOff after a 21 | // failed operation returns. 22 | func Retry(o Operation, b BackOff) error { return RetryNotify(o, b, nil) } 23 | 24 | // RetryNotify calls notify function with the error and wait duration 25 | // for each failed attempt before sleep. 26 | func RetryNotify(operation Operation, b BackOff, notify Notify) error { 27 | var err error 28 | var next time.Duration 29 | 30 | b.Reset() 31 | for { 32 | if err = operation(); err == nil { 33 | return nil 34 | } 35 | 36 | if next = b.NextBackOff(); next == Stop { 37 | return err 38 | } 39 | 40 | if notify != nil { 41 | notify(err, next) 42 | } 43 | 44 | time.Sleep(next) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/bpf/asm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package bpf 6 | 7 | import "fmt" 8 | 9 | // Assemble converts insts into raw instructions suitable for loading 10 | // into a BPF virtual machine. 11 | // 12 | // Currently, no optimization is attempted, the assembled program flow 13 | // is exactly as provided. 14 | func Assemble(insts []Instruction) ([]RawInstruction, error) { 15 | ret := make([]RawInstruction, len(insts)) 16 | var err error 17 | for i, inst := range insts { 18 | ret[i], err = inst.Assemble() 19 | if err != nil { 20 | return nil, fmt.Errorf("assembling instruction %d: %s", i+1, err) 21 | } 22 | } 23 | return ret, nil 24 | } 25 | 26 | // Disassemble attempts to parse raw back into 27 | // Instructions. Unrecognized RawInstructions are assumed to be an 28 | // extension not implemented by this package, and are passed through 29 | // unchanged to the output. The allDecoded value reports whether insts 30 | // contains no RawInstructions. 31 | func Disassemble(raw []RawInstruction) (insts []Instruction, allDecoded bool) { 32 | insts = make([]Instruction, len(raw)) 33 | allDecoded = true 34 | for i, r := range raw { 35 | insts[i] = r.Disassemble() 36 | if _, ok := insts[i].(RawInstruction); ok { 37 | allDecoded = false 38 | } 39 | } 40 | return insts, allDecoded 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/prefix_suffix.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type PrefixSuffix struct { 9 | Prefix, Suffix string 10 | } 11 | 12 | func NewPrefixSuffix(p, s string) PrefixSuffix { 13 | return PrefixSuffix{p, s} 14 | } 15 | 16 | func (self PrefixSuffix) Index(s string) (int, []int) { 17 | prefixIdx := strings.Index(s, self.Prefix) 18 | if prefixIdx == -1 { 19 | return -1, nil 20 | } 21 | 22 | suffixLen := len(self.Suffix) 23 | if suffixLen <= 0 { 24 | return prefixIdx, []int{len(s) - prefixIdx} 25 | } 26 | 27 | if (len(s) - prefixIdx) <= 0 { 28 | return -1, nil 29 | } 30 | 31 | segments := acquireSegments(len(s) - prefixIdx) 32 | for sub := s[prefixIdx:]; ; { 33 | suffixIdx := strings.LastIndex(sub, self.Suffix) 34 | if suffixIdx == -1 { 35 | break 36 | } 37 | 38 | segments = append(segments, suffixIdx+suffixLen) 39 | sub = sub[:suffixIdx] 40 | } 41 | 42 | if len(segments) == 0 { 43 | releaseSegments(segments) 44 | return -1, nil 45 | } 46 | 47 | reverseSegments(segments) 48 | 49 | return prefixIdx, segments 50 | } 51 | 52 | func (self PrefixSuffix) Len() int { 53 | return lenNo 54 | } 55 | 56 | func (self PrefixSuffix) Match(s string) bool { 57 | return strings.HasPrefix(s, self.Prefix) && strings.HasSuffix(s, self.Suffix) 58 | } 59 | 60 | func (self PrefixSuffix) String() string { 61 | return fmt.Sprintf("", self.Prefix, self.Suffix) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/ignore/cache.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package ignore 8 | 9 | import "time" 10 | 11 | type nower interface { 12 | Now() time.Time 13 | } 14 | 15 | var clock = nower(defaultClock{}) 16 | 17 | type cache struct { 18 | patterns []Pattern 19 | entries map[string]cacheEntry 20 | } 21 | 22 | type cacheEntry struct { 23 | result Result 24 | access time.Time 25 | } 26 | 27 | func newCache(patterns []Pattern) *cache { 28 | return &cache{ 29 | patterns: patterns, 30 | entries: make(map[string]cacheEntry), 31 | } 32 | } 33 | 34 | func (c *cache) clean(d time.Duration) { 35 | for k, v := range c.entries { 36 | if clock.Now().Sub(v.access) > d { 37 | delete(c.entries, k) 38 | } 39 | } 40 | } 41 | 42 | func (c *cache) get(key string) (Result, bool) { 43 | entry, ok := c.entries[key] 44 | if ok { 45 | entry.access = clock.Now() 46 | c.entries[key] = entry 47 | } 48 | return entry.result, ok 49 | } 50 | 51 | func (c *cache) set(key string, result Result) { 52 | c.entries[key] = cacheEntry{result, time.Now()} 53 | } 54 | 55 | func (c *cache) len() int { 56 | l := len(c.entries) 57 | return l 58 | } 59 | 60 | type defaultClock struct{} 61 | 62 | func (defaultClock) Now() time.Time { 63 | return time.Now() 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/payload_nocmsg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 windows 6 | 7 | package ipv6 8 | 9 | import ( 10 | "net" 11 | "syscall" 12 | ) 13 | 14 | // ReadFrom reads a payload of the received IPv6 datagram, from the 15 | // endpoint c, copying the payload into b. It returns the number of 16 | // bytes copied into b, the control message cm and the source address 17 | // src of the received datagram. 18 | func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { 19 | if !c.ok() { 20 | return 0, nil, nil, syscall.EINVAL 21 | } 22 | if n, src, err = c.PacketConn.ReadFrom(b); err != nil { 23 | return 0, nil, nil, err 24 | } 25 | return 26 | } 27 | 28 | // WriteTo writes a payload of the IPv6 datagram, to the destination 29 | // address dst through the endpoint c, copying the payload from b. It 30 | // returns the number of bytes written. The control message cm allows 31 | // the IPv6 header fields and the datagram path to be specified. The 32 | // cm may be nil if control of the outgoing datagram is not required. 33 | func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { 34 | if !c.ok() { 35 | return 0, syscall.EINVAL 36 | } 37 | if dst == nil { 38 | return 0, errMissingAddress 39 | } 40 | return c.PacketConn.WriteTo(b, dst) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/text/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/row.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Row struct { 8 | Matchers Matchers 9 | RunesLength int 10 | Segments []int 11 | } 12 | 13 | func NewRow(len int, m ...Matcher) Row { 14 | return Row{ 15 | Matchers: Matchers(m), 16 | RunesLength: len, 17 | Segments: []int{len}, 18 | } 19 | } 20 | 21 | func (self Row) matchAll(s string) bool { 22 | var idx int 23 | for _, m := range self.Matchers { 24 | length := m.Len() 25 | 26 | var next, i int 27 | for next = range s[idx:] { 28 | i++ 29 | if i == length { 30 | break 31 | } 32 | } 33 | 34 | if i < length || !m.Match(s[idx:idx+next+1]) { 35 | return false 36 | } 37 | 38 | idx += next + 1 39 | } 40 | 41 | return true 42 | } 43 | 44 | func (self Row) lenOk(s string) bool { 45 | var i int 46 | for range s { 47 | i++ 48 | if i > self.RunesLength { 49 | return false 50 | } 51 | } 52 | return self.RunesLength == i 53 | } 54 | 55 | func (self Row) Match(s string) bool { 56 | return self.lenOk(s) && self.matchAll(s) 57 | } 58 | 59 | func (self Row) Len() (l int) { 60 | return self.RunesLength 61 | } 62 | 63 | func (self Row) Index(s string) (int, []int) { 64 | for i := range s { 65 | if len(s[i:]) < self.RunesLength { 66 | break 67 | } 68 | if self.matchAll(s[i:]) { 69 | return i, self.Segments 70 | } 71 | } 72 | return -1, nil 73 | } 74 | 75 | func (self Row) String() string { 76 | return fmt.Sprintf("", self.RunesLength, self.Matchers) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt_asmreq_posix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd solaris windows 6 | 7 | package ipv4 8 | 9 | import ( 10 | "net" 11 | "os" 12 | "unsafe" 13 | 14 | "golang.org/x/net/internal/iana" 15 | ) 16 | 17 | func setsockoptIPMreq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { 18 | mreq := ipMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}} 19 | if err := setIPMreqInterface(&mreq, ifi); err != nil { 20 | return err 21 | } 22 | return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&mreq), sizeofIPMreq)) 23 | } 24 | 25 | func getsockoptInterface(s uintptr, name int) (*net.Interface, error) { 26 | var b [4]byte 27 | l := uint32(4) 28 | if err := getsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), &l); err != nil { 29 | return nil, os.NewSyscallError("getsockopt", err) 30 | } 31 | ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3])) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return ifi, nil 36 | } 37 | 38 | func setsockoptInterface(s uintptr, name int, ifi *net.Interface) error { 39 | ip, err := netInterfaceToIP4(ifi) 40 | if err != nil { 41 | return err 42 | } 43 | var b [4]byte 44 | copy(b[:], ip) 45 | return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), uint32(4))) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/payload_nocmsg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build plan9 windows 6 | 7 | package ipv4 8 | 9 | import ( 10 | "net" 11 | "syscall" 12 | ) 13 | 14 | // ReadFrom reads a payload of the received IPv4 datagram, from the 15 | // endpoint c, copying the payload into b. It returns the number of 16 | // bytes copied into b, the control message cm and the source address 17 | // src of the received datagram. 18 | func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { 19 | if !c.ok() { 20 | return 0, nil, nil, syscall.EINVAL 21 | } 22 | if n, src, err = c.PacketConn.ReadFrom(b); err != nil { 23 | return 0, nil, nil, err 24 | } 25 | return 26 | } 27 | 28 | // WriteTo writes a payload of the IPv4 datagram, to the destination 29 | // address dst through the endpoint c, copying the payload from b. It 30 | // returns the number of bytes written. The control message cm allows 31 | // the datagram path and the outgoing interface to be specified. 32 | // Currently only Darwin and Linux support this. The cm may be nil if 33 | // control of the outgoing datagram is not required. 34 | func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { 35 | if !c.ok() { 36 | return 0, syscall.EINVAL 37 | } 38 | if dst == nil { 39 | return 0, errMissingAddress 40 | } 41 | return c.PacketConn.WriteTo(b, dst) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/any_of.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type AnyOf struct { 8 | Matchers Matchers 9 | } 10 | 11 | func NewAnyOf(m ...Matcher) AnyOf { 12 | return AnyOf{Matchers(m)} 13 | } 14 | 15 | func (self *AnyOf) Add(m Matcher) error { 16 | self.Matchers = append(self.Matchers, m) 17 | return nil 18 | } 19 | 20 | func (self AnyOf) Match(s string) bool { 21 | for _, m := range self.Matchers { 22 | if m.Match(s) { 23 | return true 24 | } 25 | } 26 | 27 | return false 28 | } 29 | 30 | func (self AnyOf) Index(s string) (int, []int) { 31 | index := -1 32 | 33 | segments := acquireSegments(len(s)) 34 | for _, m := range self.Matchers { 35 | idx, seg := m.Index(s) 36 | if idx == -1 { 37 | continue 38 | } 39 | 40 | if index == -1 || idx < index { 41 | index = idx 42 | segments = append(segments[:0], seg...) 43 | continue 44 | } 45 | 46 | if idx > index { 47 | continue 48 | } 49 | 50 | // here idx == index 51 | segments = appendMerge(segments, seg) 52 | } 53 | 54 | if index == -1 { 55 | releaseSegments(segments) 56 | return -1, nil 57 | } 58 | 59 | return index, segments 60 | } 61 | 62 | func (self AnyOf) Len() (l int) { 63 | l = -1 64 | for _, m := range self.Matchers { 65 | ml := m.Len() 66 | switch { 67 | case l == -1: 68 | l = ml 69 | continue 70 | 71 | case ml == -1: 72 | return -1 73 | 74 | case l != ml: 75 | return -1 76 | } 77 | } 78 | 79 | return 80 | } 81 | 82 | func (self AnyOf) String() string { 83 | return fmt.Sprintf("", self.Matchers) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/helper.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import ( 8 | "encoding/binary" 9 | "errors" 10 | "net" 11 | "unsafe" 12 | ) 13 | 14 | var ( 15 | errMissingAddress = errors.New("missing address") 16 | errMissingHeader = errors.New("missing header") 17 | errHeaderTooShort = errors.New("header too short") 18 | errBufferTooShort = errors.New("buffer too short") 19 | errInvalidConnType = errors.New("invalid conn type") 20 | errOpNoSupport = errors.New("operation not supported") 21 | errNoSuchInterface = errors.New("no such interface") 22 | errNoSuchMulticastInterface = errors.New("no such multicast interface") 23 | 24 | // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html. 25 | freebsdVersion uint32 26 | 27 | nativeEndian binary.ByteOrder 28 | ) 29 | 30 | func init() { 31 | i := uint32(1) 32 | b := (*[4]byte)(unsafe.Pointer(&i)) 33 | if b[0] == 1 { 34 | nativeEndian = binary.LittleEndian 35 | } else { 36 | nativeEndian = binary.BigEndian 37 | } 38 | } 39 | 40 | func boolint(b bool) int { 41 | if b { 42 | return 1 43 | } 44 | return 0 45 | } 46 | 47 | func netAddrToIP4(a net.Addr) net.IP { 48 | switch v := a.(type) { 49 | case *net.UDPAddr: 50 | if ip := v.IP.To4(); ip != nil { 51 | return ip 52 | } 53 | case *net.IPAddr: 54 | if ip := v.IP.To4(); ip != nil { 55 | return ip 56 | } 57 | } 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/match.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | // todo common table of rune's length 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | ) 9 | 10 | const lenOne = 1 11 | const lenZero = 0 12 | const lenNo = -1 13 | 14 | type Matcher interface { 15 | Match(string) bool 16 | Index(string) (int, []int) 17 | Len() int 18 | String() string 19 | } 20 | 21 | type Matchers []Matcher 22 | 23 | func (m Matchers) String() string { 24 | var s []string 25 | for _, matcher := range m { 26 | s = append(s, fmt.Sprint(matcher)) 27 | } 28 | 29 | return fmt.Sprintf("%s", strings.Join(s, ",")) 30 | } 31 | 32 | // appendMerge merges and sorts given already SORTED and UNIQUE segments. 33 | func appendMerge(target, sub []int) []int { 34 | lt, ls := len(target), len(sub) 35 | out := make([]int, 0, lt+ls) 36 | 37 | for x, y := 0, 0; x < lt || y < ls; { 38 | if x >= lt { 39 | out = append(out, sub[y:]...) 40 | break 41 | } 42 | 43 | if y >= ls { 44 | out = append(out, target[x:]...) 45 | break 46 | } 47 | 48 | xValue := target[x] 49 | yValue := sub[y] 50 | 51 | switch { 52 | 53 | case xValue == yValue: 54 | out = append(out, xValue) 55 | x++ 56 | y++ 57 | 58 | case xValue < yValue: 59 | out = append(out, xValue) 60 | x++ 61 | 62 | case yValue < xValue: 63 | out = append(out, yValue) 64 | y++ 65 | 66 | } 67 | } 68 | 69 | target = append(target[:0], out...) 70 | 71 | return target 72 | } 73 | 74 | func reverseSegments(input []int) { 75 | l := len(input) 76 | m := l / 2 77 | 78 | for i := 0; i < m; i++ { 79 | input[i], input[l-i-1] = input[l-i-1], input[i] 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/debug/debug.go: -------------------------------------------------------------------------------- 1 | package debug 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "github.com/gobwas/glob/match" 7 | "math/rand" 8 | ) 9 | 10 | func Graphviz(pattern string, m match.Matcher) string { 11 | return fmt.Sprintf(`digraph G {graph[label="%s"];%s}`, pattern, graphviz_internal(m, fmt.Sprintf("%x", rand.Int63()))) 12 | } 13 | 14 | func graphviz_internal(m match.Matcher, id string) string { 15 | buf := &bytes.Buffer{} 16 | 17 | switch matcher := m.(type) { 18 | case match.BTree: 19 | fmt.Fprintf(buf, `"%s"[label="%s"];`, id, matcher.Value.String()) 20 | for _, m := range []match.Matcher{matcher.Left, matcher.Right} { 21 | switch n := m.(type) { 22 | case nil: 23 | rnd := rand.Int63() 24 | fmt.Fprintf(buf, `"%x"[label=""];`, rnd) 25 | fmt.Fprintf(buf, `"%s"->"%x";`, id, rnd) 26 | 27 | default: 28 | sub := fmt.Sprintf("%x", rand.Int63()) 29 | fmt.Fprintf(buf, `"%s"->"%s";`, id, sub) 30 | fmt.Fprintf(buf, graphviz_internal(n, sub)) 31 | } 32 | } 33 | 34 | case match.AnyOf: 35 | fmt.Fprintf(buf, `"%s"[label="AnyOf"];`, id) 36 | for _, m := range matcher.Matchers { 37 | rnd := rand.Int63() 38 | fmt.Fprintf(buf, graphviz_internal(m, fmt.Sprintf("%x", rnd))) 39 | fmt.Fprintf(buf, `"%s"->"%x";`, id, rnd) 40 | } 41 | 42 | case match.EveryOf: 43 | fmt.Fprintf(buf, `"%s"[label="EveryOf"];`, id) 44 | for _, m := range matcher.Matchers { 45 | rnd := rand.Int63() 46 | fmt.Fprintf(buf, graphviz_internal(m, fmt.Sprintf("%x", rnd))) 47 | fmt.Fprintf(buf, `"%s"->"%x";`, id, rnd) 48 | } 49 | 50 | default: 51 | fmt.Fprintf(buf, `"%s"[label="%s"];`, id, m.String()) 52 | } 53 | 54 | return buf.String() 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/genericopt_posix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris windows 6 | 7 | package ipv4 8 | 9 | import ( 10 | "syscall" 11 | 12 | "golang.org/x/net/internal/netreflect" 13 | ) 14 | 15 | // TOS returns the type-of-service field value for outgoing packets. 16 | func (c *genericOpt) TOS() (int, error) { 17 | if !c.ok() { 18 | return 0, syscall.EINVAL 19 | } 20 | s, err := netreflect.SocketOf(c.Conn) 21 | if err != nil { 22 | return 0, err 23 | } 24 | return getInt(s, &sockOpts[ssoTOS]) 25 | } 26 | 27 | // SetTOS sets the type-of-service field value for future outgoing 28 | // packets. 29 | func (c *genericOpt) SetTOS(tos int) error { 30 | if !c.ok() { 31 | return syscall.EINVAL 32 | } 33 | s, err := netreflect.SocketOf(c.Conn) 34 | if err != nil { 35 | return err 36 | } 37 | return setInt(s, &sockOpts[ssoTOS], tos) 38 | } 39 | 40 | // TTL returns the time-to-live field value for outgoing packets. 41 | func (c *genericOpt) TTL() (int, error) { 42 | if !c.ok() { 43 | return 0, syscall.EINVAL 44 | } 45 | s, err := netreflect.SocketOf(c.Conn) 46 | if err != nil { 47 | return 0, err 48 | } 49 | return getInt(s, &sockOpts[ssoTTL]) 50 | } 51 | 52 | // SetTTL sets the time-to-live field value for future outgoing 53 | // packets. 54 | func (c *genericOpt) SetTTL(ttl int) error { 55 | if !c.ok() { 56 | return syscall.EINVAL 57 | } 58 | s, err := netreflect.SocketOf(c.Conn) 59 | if err != nil { 60 | return err 61 | } 62 | return setInt(s, &sockOpts[ssoTTL], ttl) 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /rlimit_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package main 10 | 11 | import "syscall" 12 | 13 | // MaximizeOpenFileLimit tries to set the resoure limit RLIMIT_NOFILE (number 14 | // of open file descriptors) to the max (hard limit), if the current (soft 15 | // limit) is below the max. Returns the new (though possibly unchanged) limit, 16 | // or an error if it could not be changed. 17 | func MaximizeOpenFileLimit() (int, error) { 18 | // Get the current limit on number of open files. 19 | var lim syscall.Rlimit 20 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil { 21 | return 0, err 22 | } 23 | 24 | // If we're already at max, there's no need to try to raise the limit. 25 | if lim.Cur >= lim.Max { 26 | return int(lim.Cur), nil 27 | } 28 | 29 | // Try to increase the limit to the max. 30 | oldLimit := lim.Cur 31 | lim.Cur = lim.Max 32 | if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil { 33 | return int(oldLimit), err 34 | } 35 | 36 | // If the set succeeded, perform a new get to see what happened. We might 37 | // have gotten a value lower than the one in lim.Max, if lim.Max was 38 | // something that indiciated "unlimited" (i.e. intmax). 39 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil { 40 | // We don't really know the correct value here since Getrlimit 41 | // mysteriously failed after working once... Shouldn't ever happen, I 42 | // think. 43 | return 0, err 44 | } 45 | 46 | return int(lim.Cur), nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin freebsd linux solaris 6 | 7 | package ipv6 8 | 9 | import ( 10 | "net" 11 | "os" 12 | "unsafe" 13 | ) 14 | 15 | var freebsd32o64 bool 16 | 17 | func setsockoptGroupReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { 18 | var gr groupReq 19 | if ifi != nil { 20 | gr.Interface = uint32(ifi.Index) 21 | } 22 | gr.setGroup(grp) 23 | var p unsafe.Pointer 24 | var l uint32 25 | if freebsd32o64 { 26 | var d [sizeofGroupReq + 4]byte 27 | s := (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr)) 28 | copy(d[:4], s[:4]) 29 | copy(d[8:], s[4:]) 30 | p = unsafe.Pointer(&d[0]) 31 | l = sizeofGroupReq + 4 32 | } else { 33 | p = unsafe.Pointer(&gr) 34 | l = sizeofGroupReq 35 | } 36 | return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, p, l)) 37 | } 38 | 39 | func setsockoptGroupSourceReq(s uintptr, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { 40 | var gsr groupSourceReq 41 | if ifi != nil { 42 | gsr.Interface = uint32(ifi.Index) 43 | } 44 | gsr.setSourceGroup(grp, src) 45 | var p unsafe.Pointer 46 | var l uint32 47 | if freebsd32o64 { 48 | var d [sizeofGroupSourceReq + 4]byte 49 | s := (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) 50 | copy(d[:4], s[:4]) 51 | copy(d[8:], s[4:]) 52 | p = unsafe.Pointer(&d[0]) 53 | l = sizeofGroupSourceReq + 4 54 | } else { 55 | p = unsafe.Pointer(&gsr) 56 | l = sizeofGroupSourceReq 57 | } 58 | return os.NewSyscallError("setsockopt", setsockopt(s, opt.level, opt.name, p, l)) 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/ignore/tempname.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package ignore 8 | 9 | import ( 10 | "crypto/md5" 11 | "fmt" 12 | "path/filepath" 13 | "runtime" 14 | "strings" 15 | ) 16 | 17 | const ( 18 | WindowsTempPrefix = "~syncthing~" 19 | UnixTempPrefix = ".syncthing." 20 | ) 21 | 22 | var TempPrefix string 23 | 24 | // Real filesystems usually handle 255 bytes. encfs has varying and 25 | // confusing file name limits. We take a safe way out and switch to hashing 26 | // quite early. 27 | const maxFilenameLength = 160 - len(UnixTempPrefix) - len(".tmp") 28 | 29 | func init() { 30 | if runtime.GOOS == "windows" { 31 | TempPrefix = WindowsTempPrefix 32 | } else { 33 | TempPrefix = UnixTempPrefix 34 | } 35 | } 36 | 37 | // IsTemporary is true if the file name has the temporary prefix. Regardless 38 | // of the normally used prefix, the standard Windows and Unix temp prefixes 39 | // are always recognized as temp files. 40 | func IsTemporary(name string) bool { 41 | name = filepath.Base(name) 42 | if strings.HasPrefix(name, WindowsTempPrefix) || 43 | strings.HasPrefix(name, UnixTempPrefix) { 44 | return true 45 | } 46 | return false 47 | } 48 | 49 | func TempName(name string) string { 50 | tdir := filepath.Dir(name) 51 | tbase := filepath.Base(name) 52 | if len(tbase) > maxFilenameLength { 53 | hash := md5.New() 54 | hash.Write([]byte(name)) 55 | tbase = fmt.Sprintf("%x", hash.Sum(nil)) 56 | } 57 | tname := fmt.Sprintf("%s%s.tmp", TempPrefix, tbase) 58 | return filepath.Join(tdir, tname) 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/header.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import ( 8 | "encoding/binary" 9 | "fmt" 10 | "net" 11 | ) 12 | 13 | const ( 14 | Version = 6 // protocol version 15 | HeaderLen = 40 // header length 16 | ) 17 | 18 | // A Header represents an IPv6 base header. 19 | type Header struct { 20 | Version int // protocol version 21 | TrafficClass int // traffic class 22 | FlowLabel int // flow label 23 | PayloadLen int // payload length 24 | NextHeader int // next header 25 | HopLimit int // hop limit 26 | Src net.IP // source address 27 | Dst net.IP // destination address 28 | } 29 | 30 | func (h *Header) String() string { 31 | if h == nil { 32 | return "" 33 | } 34 | return fmt.Sprintf("ver=%d tclass=%#x flowlbl=%#x payloadlen=%d nxthdr=%d hoplim=%d src=%v dst=%v", h.Version, h.TrafficClass, h.FlowLabel, h.PayloadLen, h.NextHeader, h.HopLimit, h.Src, h.Dst) 35 | } 36 | 37 | // ParseHeader parses b as an IPv6 base header. 38 | func ParseHeader(b []byte) (*Header, error) { 39 | if len(b) < HeaderLen { 40 | return nil, errHeaderTooShort 41 | } 42 | h := &Header{ 43 | Version: int(b[0]) >> 4, 44 | TrafficClass: int(b[0]&0x0f)<<4 | int(b[1])>>4, 45 | FlowLabel: int(b[1]&0x0f)<<16 | int(b[2])<<8 | int(b[3]), 46 | PayloadLen: int(binary.BigEndian.Uint16(b[4:6])), 47 | NextHeader: int(b[6]), 48 | HopLimit: int(b[7]), 49 | } 50 | h.Src = make(net.IP, net.IPv6len) 51 | copy(h.Src, b[8:24]) 52 | h.Dst = make(net.IP, net.IPv6len) 53 | copy(h.Dst, b[24:40]) 54 | return h, nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin 6 | 7 | package ipv6 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | 13 | "golang.org/x/net/internal/iana" 14 | ) 15 | 16 | func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte { 17 | m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 18 | m.Level = iana.ProtocolIPv6 19 | m.Type = sysIPV6_2292HOPLIMIT 20 | m.SetLen(syscall.CmsgLen(4)) 21 | if cm != nil { 22 | data := b[syscall.CmsgLen(0):] 23 | nativeEndian.PutUint32(data[:4], uint32(cm.HopLimit)) 24 | } 25 | return b[syscall.CmsgSpace(4):] 26 | } 27 | 28 | func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte { 29 | m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 30 | m.Level = iana.ProtocolIPv6 31 | m.Type = sysIPV6_2292PKTINFO 32 | m.SetLen(syscall.CmsgLen(sizeofInet6Pktinfo)) 33 | if cm != nil { 34 | pi := (*inet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) 35 | if ip := cm.Src.To16(); ip != nil && ip.To4() == nil { 36 | copy(pi.Addr[:], ip) 37 | } 38 | if cm.IfIndex > 0 { 39 | pi.setIfindex(cm.IfIndex) 40 | } 41 | } 42 | return b[syscall.CmsgSpace(sizeofInet6Pktinfo):] 43 | } 44 | 45 | func marshal2292NextHop(b []byte, cm *ControlMessage) []byte { 46 | m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) 47 | m.Level = iana.ProtocolIPv6 48 | m.Type = sysIPV6_2292NEXTHOP 49 | m.SetLen(syscall.CmsgLen(sizeofSockaddrInet6)) 50 | if cm != nil { 51 | sa := (*sockaddrInet6)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) 52 | sa.setSockaddr(cm.NextHop, cm.IfIndex) 53 | } 54 | return b[syscall.CmsgSpace(sizeofSockaddrInet6):] 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/lib/osutil/rlimit_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package osutil 10 | 11 | import "syscall" 12 | 13 | // MaximizeOpenFileLimit tries to set the resource limit RLIMIT_NOFILE (number 14 | // of open file descriptors) to the max (hard limit), if the current (soft 15 | // limit) is below the max. Returns the new (though possibly unchanged) limit, 16 | // or an error if it could not be changed. 17 | func MaximizeOpenFileLimit() (int, error) { 18 | // Get the current limit on number of open files. 19 | var lim syscall.Rlimit 20 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil { 21 | return 0, err 22 | } 23 | 24 | // If we're already at max, there's no need to try to raise the limit. 25 | if lim.Cur >= lim.Max { 26 | return int(lim.Cur), nil 27 | } 28 | 29 | // Try to increase the limit to the max. 30 | oldLimit := lim.Cur 31 | lim.Cur = lim.Max 32 | if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil { 33 | return int(oldLimit), err 34 | } 35 | 36 | // If the set succeeded, perform a new get to see what happened. We might 37 | // have gotten a value lower than the one in lim.Max, if lim.Max was 38 | // something that indicated "unlimited" (i.e. intmax). 39 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil { 40 | // We don't really know the correct value here since Getrlimit 41 | // mysteriously failed after working once... Shouldn't ever happen, I 42 | // think. 43 | return 0, err 44 | } 45 | 46 | return int(lim.Cur), nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin freebsd linux solaris 6 | 7 | package ipv4 8 | 9 | import ( 10 | "net" 11 | "os" 12 | "unsafe" 13 | 14 | "golang.org/x/net/internal/iana" 15 | ) 16 | 17 | var freebsd32o64 bool 18 | 19 | func setsockoptGroupReq(s uintptr, name int, ifi *net.Interface, grp net.IP) error { 20 | var gr groupReq 21 | if ifi != nil { 22 | gr.Interface = uint32(ifi.Index) 23 | } 24 | gr.setGroup(grp) 25 | var p unsafe.Pointer 26 | var l uint32 27 | if freebsd32o64 { 28 | var d [sizeofGroupReq + 4]byte 29 | s := (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr)) 30 | copy(d[:4], s[:4]) 31 | copy(d[8:], s[4:]) 32 | p = unsafe.Pointer(&d[0]) 33 | l = sizeofGroupReq + 4 34 | } else { 35 | p = unsafe.Pointer(&gr) 36 | l = sizeofGroupReq 37 | } 38 | return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, p, l)) 39 | } 40 | 41 | func setsockoptGroupSourceReq(s uintptr, name int, ifi *net.Interface, grp, src net.IP) error { 42 | var gsr groupSourceReq 43 | if ifi != nil { 44 | gsr.Interface = uint32(ifi.Index) 45 | } 46 | gsr.setSourceGroup(grp, src) 47 | var p unsafe.Pointer 48 | var l uint32 49 | if freebsd32o64 { 50 | var d [sizeofGroupSourceReq + 4]byte 51 | s := (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) 52 | copy(d[:4], s[:4]) 53 | copy(d[8:], s[4:]) 54 | p = unsafe.Pointer(&d[0]) 55 | l = sizeofGroupSourceReq + 4 56 | } else { 57 | p = unsafe.Pointer(&gsr) 58 | l = sizeofGroupSourceReq 59 | } 60 | return os.NewSyscallError("setsockopt", setsockopt(s, iana.ProtocolIP, name, p, l)) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/genericopt_posix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris windows 6 | 7 | package ipv6 8 | 9 | import ( 10 | "syscall" 11 | 12 | "golang.org/x/net/internal/netreflect" 13 | ) 14 | 15 | // TrafficClass returns the traffic class field value for outgoing 16 | // packets. 17 | func (c *genericOpt) TrafficClass() (int, error) { 18 | if !c.ok() { 19 | return 0, syscall.EINVAL 20 | } 21 | s, err := netreflect.SocketOf(c.Conn) 22 | if err != nil { 23 | return 0, err 24 | } 25 | return getInt(s, &sockOpts[ssoTrafficClass]) 26 | } 27 | 28 | // SetTrafficClass sets the traffic class field value for future 29 | // outgoing packets. 30 | func (c *genericOpt) SetTrafficClass(tclass int) error { 31 | if !c.ok() { 32 | return syscall.EINVAL 33 | } 34 | s, err := netreflect.SocketOf(c.Conn) 35 | if err != nil { 36 | return err 37 | } 38 | return setInt(s, &sockOpts[ssoTrafficClass], tclass) 39 | } 40 | 41 | // HopLimit returns the hop limit field value for outgoing packets. 42 | func (c *genericOpt) HopLimit() (int, error) { 43 | if !c.ok() { 44 | return 0, syscall.EINVAL 45 | } 46 | s, err := netreflect.SocketOf(c.Conn) 47 | if err != nil { 48 | return 0, err 49 | } 50 | return getInt(s, &sockOpts[ssoHopLimit]) 51 | } 52 | 53 | // SetHopLimit sets the hop limit field value for future outgoing 54 | // packets. 55 | func (c *genericOpt) SetHopLimit(hoplim int) error { 56 | if !c.ok() { 57 | return syscall.EINVAL 58 | } 59 | s, err := netreflect.SocketOf(c.Conn) 60 | if err != nil { 61 | return err 62 | } 63 | return setInt(s, &sockOpts[ssoHopLimit], hoplim) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/icmp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | import "golang.org/x/net/internal/iana" 8 | 9 | // An ICMPType represents a type of ICMP message. 10 | type ICMPType int 11 | 12 | func (typ ICMPType) String() string { 13 | s, ok := icmpTypes[typ] 14 | if !ok { 15 | return "" 16 | } 17 | return s 18 | } 19 | 20 | // Protocol returns the ICMPv4 protocol number. 21 | func (typ ICMPType) Protocol() int { 22 | return iana.ProtocolICMP 23 | } 24 | 25 | // An ICMPFilter represents an ICMP message filter for incoming 26 | // packets. The filter belongs to a packet delivery path on a host and 27 | // it cannot interact with forwarding packets or tunnel-outer packets. 28 | // 29 | // Note: RFC 2460 defines a reasonable role model and it works not 30 | // only for IPv6 but IPv4. A node means a device that implements IP. 31 | // A router means a node that forwards IP packets not explicitly 32 | // addressed to itself, and a host means a node that is not a router. 33 | type ICMPFilter struct { 34 | icmpFilter 35 | } 36 | 37 | // Accept accepts incoming ICMP packets including the type field value 38 | // typ. 39 | func (f *ICMPFilter) Accept(typ ICMPType) { 40 | f.accept(typ) 41 | } 42 | 43 | // Block blocks incoming ICMP packets including the type field value 44 | // typ. 45 | func (f *ICMPFilter) Block(typ ICMPType) { 46 | f.block(typ) 47 | } 48 | 49 | // SetAll sets the filter action to the filter. 50 | func (f *ICMPFilter) SetAll(block bool) { 51 | f.setAll(block) 52 | } 53 | 54 | // WillBlock reports whether the ICMP type will be blocked. 55 | func (f *ICMPFilter) WillBlock(typ ICMPType) bool { 56 | return f.willBlock(typ) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/icmp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv6 6 | 7 | import "golang.org/x/net/internal/iana" 8 | 9 | // BUG(mikio): On Windows, methods related to ICMPFilter are not 10 | // implemented. 11 | 12 | // An ICMPType represents a type of ICMP message. 13 | type ICMPType int 14 | 15 | func (typ ICMPType) String() string { 16 | s, ok := icmpTypes[typ] 17 | if !ok { 18 | return "" 19 | } 20 | return s 21 | } 22 | 23 | // Protocol returns the ICMPv6 protocol number. 24 | func (typ ICMPType) Protocol() int { 25 | return iana.ProtocolIPv6ICMP 26 | } 27 | 28 | // An ICMPFilter represents an ICMP message filter for incoming 29 | // packets. The filter belongs to a packet delivery path on a host and 30 | // it cannot interact with forwarding packets or tunnel-outer packets. 31 | // 32 | // Note: RFC 2460 defines a reasonable role model. A node means a 33 | // device that implements IP. A router means a node that forwards IP 34 | // packets not explicitly addressed to itself, and a host means a node 35 | // that is not a router. 36 | type ICMPFilter struct { 37 | icmpv6Filter 38 | } 39 | 40 | // Accept accepts incoming ICMP packets including the type field value 41 | // typ. 42 | func (f *ICMPFilter) Accept(typ ICMPType) { 43 | f.accept(typ) 44 | } 45 | 46 | // Block blocks incoming ICMP packets including the type field value 47 | // typ. 48 | func (f *ICMPFilter) Block(typ ICMPType) { 49 | f.block(typ) 50 | } 51 | 52 | // SetAll sets the filter action to the filter. 53 | func (f *ICMPFilter) SetAll(block bool) { 54 | f.setAll(block) 55 | } 56 | 57 | // WillBlock reports whether the ICMP type will be blocked. 58 | func (f *ICMPFilter) WillBlock(typ ICMPType) bool { 59 | return f.willBlock(typ) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/gobwas/glob/match/segments.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | type SomePool interface { 8 | Get() []int 9 | Put([]int) 10 | } 11 | 12 | var segmentsPools [1024]sync.Pool 13 | 14 | func toPowerOfTwo(v int) int { 15 | v-- 16 | v |= v >> 1 17 | v |= v >> 2 18 | v |= v >> 4 19 | v |= v >> 8 20 | v |= v >> 16 21 | v++ 22 | 23 | return v 24 | } 25 | 26 | const ( 27 | cacheFrom = 16 28 | cacheToAndHigher = 1024 29 | cacheFromIndex = 15 30 | cacheToAndHigherIndex = 1023 31 | ) 32 | 33 | var ( 34 | segments0 = []int{0} 35 | segments1 = []int{1} 36 | segments2 = []int{2} 37 | segments3 = []int{3} 38 | segments4 = []int{4} 39 | ) 40 | 41 | var segmentsByRuneLength [5][]int = [5][]int{ 42 | 0: segments0, 43 | 1: segments1, 44 | 2: segments2, 45 | 3: segments3, 46 | 4: segments4, 47 | } 48 | 49 | func init() { 50 | for i := cacheToAndHigher; i >= cacheFrom; i >>= 1 { 51 | func(i int) { 52 | segmentsPools[i-1] = sync.Pool{New: func() interface{} { 53 | return make([]int, 0, i) 54 | }} 55 | }(i) 56 | } 57 | } 58 | 59 | func getTableIndex(c int) int { 60 | p := toPowerOfTwo(c) 61 | switch { 62 | case p >= cacheToAndHigher: 63 | return cacheToAndHigherIndex 64 | case p <= cacheFrom: 65 | return cacheFromIndex 66 | default: 67 | return p - 1 68 | } 69 | } 70 | 71 | func acquireSegments(c int) []int { 72 | // make []int with less capacity than cacheFrom 73 | // is faster than acquiring it from pool 74 | if c < cacheFrom { 75 | return make([]int, 0, c) 76 | } 77 | 78 | return segmentsPools[getTableIndex(c)].Get().([]int)[:0] 79 | } 80 | 81 | func releaseSegments(s []int) { 82 | c := cap(s) 83 | 84 | // make []int with less capacity than cacheFrom 85 | // is faster than acquiring it from pool 86 | if c < cacheFrom { 87 | return 88 | } 89 | 90 | segmentsPools[getTableIndex(c)].Put(s) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/github.com/petermattis/goid/goid_go1.5.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Peter Mattis. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | // implied. See the License for the specific language governing 13 | // permissions and limitations under the License. See the AUTHORS file 14 | // for names of contributors. 15 | 16 | // +build amd64 amd64p32 arm 17 | // +build go1.5,!go1.6 18 | 19 | package goid 20 | 21 | import "unsafe" 22 | 23 | // Just enough of the structs from runtime/runtime2.go to get the offset to goid. 24 | // See https://github.com/golang/go/blob/release-branch.go1.5/src/runtime/runtime2.go 25 | 26 | type stack struct { 27 | lo uintptr 28 | hi uintptr 29 | } 30 | 31 | type gobuf struct { 32 | sp uintptr 33 | pc uintptr 34 | g uintptr 35 | ctxt uintptr 36 | ret uintptr 37 | lr uintptr 38 | bp uintptr 39 | } 40 | 41 | type g struct { 42 | stack stack 43 | stackguard0 uintptr 44 | stackguard1 uintptr 45 | 46 | _panic uintptr 47 | _defer uintptr 48 | m uintptr 49 | stackAlloc uintptr 50 | sched gobuf 51 | syscallsp uintptr 52 | syscallpc uintptr 53 | stkbar []uintptr 54 | stkbarPos uintptr 55 | param unsafe.Pointer 56 | atomicstatus uint32 57 | stackLock uint32 58 | goid int64 // Here it is! 59 | } 60 | 61 | // Backdoor access to runtime·getg(). 62 | func getg() uintptr // in goid_go1.5plus.s 63 | 64 | func Get() int64 { 65 | gg := (*g)(unsafe.Pointer(getg())) 66 | return gg.goid 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/cenkalti/backoff/ticker.go: -------------------------------------------------------------------------------- 1 | package backoff 2 | 3 | import ( 4 | "runtime" 5 | "sync" 6 | "time" 7 | ) 8 | 9 | // Ticker holds a channel that delivers `ticks' of a clock at times reported by a BackOff. 10 | // 11 | // Ticks will continue to arrive when the previous operation is still running, 12 | // so operations that take a while to fail could run in quick succession. 13 | type Ticker struct { 14 | C <-chan time.Time 15 | c chan time.Time 16 | b BackOff 17 | stop chan struct{} 18 | stopOnce sync.Once 19 | } 20 | 21 | // NewTicker returns a new Ticker containing a channel that will send the time at times 22 | // specified by the BackOff argument. Ticker is guaranteed to tick at least once. 23 | // The channel is closed when Stop method is called or BackOff stops. 24 | func NewTicker(b BackOff) *Ticker { 25 | c := make(chan time.Time) 26 | t := &Ticker{ 27 | C: c, 28 | c: c, 29 | b: b, 30 | stop: make(chan struct{}), 31 | } 32 | go t.run() 33 | runtime.SetFinalizer(t, (*Ticker).Stop) 34 | return t 35 | } 36 | 37 | // Stop turns off a ticker. After Stop, no more ticks will be sent. 38 | func (t *Ticker) Stop() { 39 | t.stopOnce.Do(func() { close(t.stop) }) 40 | } 41 | 42 | func (t *Ticker) run() { 43 | c := t.c 44 | defer close(c) 45 | t.b.Reset() 46 | 47 | // Ticker is guaranteed to tick at least once. 48 | afterC := t.send(time.Now()) 49 | 50 | for { 51 | if afterC == nil { 52 | return 53 | } 54 | 55 | select { 56 | case tick := <-afterC: 57 | afterC = t.send(tick) 58 | case <-t.stop: 59 | t.c = nil // Prevent future ticks from being sent to the channel. 60 | return 61 | } 62 | } 63 | } 64 | 65 | func (t *Ticker) send(tick time.Time) <-chan time.Time { 66 | select { 67 | case t.c <- tick: 68 | case <-t.stop: 69 | return nil 70 | } 71 | 72 | next := t.b.NextBackOff() 73 | if next == Stop { 74 | t.Stop() 75 | return nil 76 | } 77 | 78 | return time.After(next) 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sockopt.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | // Sticky socket options 8 | const ( 9 | ssoTOS = iota // header field for unicast packet 10 | ssoTTL // header field for unicast packet 11 | ssoMulticastTTL // header field for multicast packet 12 | ssoMulticastInterface // outbound interface for multicast packet 13 | ssoMulticastLoopback // loopback for multicast packet 14 | ssoReceiveTTL // header field on received packet 15 | ssoReceiveDst // header field on received packet 16 | ssoReceiveInterface // inbound interface on received packet 17 | ssoPacketInfo // incbound or outbound packet path 18 | ssoHeaderPrepend // ipv4 header prepend 19 | ssoStripHeader // strip ipv4 header 20 | ssoICMPFilter // icmp filter 21 | ssoJoinGroup // any-source multicast 22 | ssoLeaveGroup // any-source multicast 23 | ssoJoinSourceGroup // source-specific multicast 24 | ssoLeaveSourceGroup // source-specific multicast 25 | ssoBlockSourceGroup // any-source or source-specific multicast 26 | ssoUnblockSourceGroup // any-source or source-specific multicast 27 | ssoMax 28 | ) 29 | 30 | // Sticky socket option value types 31 | const ( 32 | ssoTypeByte = iota + 1 33 | ssoTypeInt 34 | ssoTypeInterface 35 | ssoTypeICMPFilter 36 | ssoTypeIPMreq 37 | ssoTypeIPMreqn 38 | ssoTypeGroupReq 39 | ssoTypeGroupSourceReq 40 | ) 41 | 42 | // A sockOpt represents a binding for sticky socket option. 43 | type sockOpt struct { 44 | name int // option name, must be equal or greater than 1 45 | typ int // option value type, must be equal or greater than 1 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv4/sys_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ipv4 6 | 7 | const ( 8 | // See ws2tcpip.h. 9 | sysIP_OPTIONS = 0x1 10 | sysIP_HDRINCL = 0x2 11 | sysIP_TOS = 0x3 12 | sysIP_TTL = 0x4 13 | sysIP_MULTICAST_IF = 0x9 14 | sysIP_MULTICAST_TTL = 0xa 15 | sysIP_MULTICAST_LOOP = 0xb 16 | sysIP_ADD_MEMBERSHIP = 0xc 17 | sysIP_DROP_MEMBERSHIP = 0xd 18 | sysIP_DONTFRAGMENT = 0xe 19 | sysIP_ADD_SOURCE_MEMBERSHIP = 0xf 20 | sysIP_DROP_SOURCE_MEMBERSHIP = 0x10 21 | sysIP_PKTINFO = 0x13 22 | 23 | sizeofInetPktinfo = 0x8 24 | sizeofIPMreq = 0x8 25 | sizeofIPMreqSource = 0xc 26 | ) 27 | 28 | type inetPktinfo struct { 29 | Addr [4]byte 30 | Ifindex int32 31 | } 32 | 33 | type ipMreq struct { 34 | Multiaddr [4]byte 35 | Interface [4]byte 36 | } 37 | 38 | type ipMreqSource struct { 39 | Multiaddr [4]byte 40 | Sourceaddr [4]byte 41 | Interface [4]byte 42 | } 43 | 44 | // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx 45 | var ( 46 | ctlOpts = [ctlMax]ctlOpt{} 47 | 48 | sockOpts = [ssoMax]sockOpt{ 49 | ssoTOS: {sysIP_TOS, ssoTypeInt}, 50 | ssoTTL: {sysIP_TTL, ssoTypeInt}, 51 | ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt}, 52 | ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, 53 | ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, 54 | ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, 55 | ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, 56 | ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, 57 | } 58 | ) 59 | 60 | func (pi *inetPktinfo) setIfindex(i int) { 61 | pi.Ifindex = int32(i) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/syncthing/syncthing/vendor/golang.org/x/net/ipv6/zsys_netbsd.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs defs_netbsd.go 3 | 4 | package ipv6 5 | 6 | const ( 7 | sysIPV6_UNICAST_HOPS = 0x4 8 | sysIPV6_MULTICAST_IF = 0x9 9 | sysIPV6_MULTICAST_HOPS = 0xa 10 | sysIPV6_MULTICAST_LOOP = 0xb 11 | sysIPV6_JOIN_GROUP = 0xc 12 | sysIPV6_LEAVE_GROUP = 0xd 13 | sysIPV6_PORTRANGE = 0xe 14 | sysICMP6_FILTER = 0x12 15 | 16 | sysIPV6_CHECKSUM = 0x1a 17 | sysIPV6_V6ONLY = 0x1b 18 | 19 | sysIPV6_IPSEC_POLICY = 0x1c 20 | 21 | sysIPV6_RTHDRDSTOPTS = 0x23 22 | 23 | sysIPV6_RECVPKTINFO = 0x24 24 | sysIPV6_RECVHOPLIMIT = 0x25 25 | sysIPV6_RECVRTHDR = 0x26 26 | sysIPV6_RECVHOPOPTS = 0x27 27 | sysIPV6_RECVDSTOPTS = 0x28 28 | 29 | sysIPV6_USE_MIN_MTU = 0x2a 30 | sysIPV6_RECVPATHMTU = 0x2b 31 | sysIPV6_PATHMTU = 0x2c 32 | 33 | sysIPV6_PKTINFO = 0x2e 34 | sysIPV6_HOPLIMIT = 0x2f 35 | sysIPV6_NEXTHOP = 0x30 36 | sysIPV6_HOPOPTS = 0x31 37 | sysIPV6_DSTOPTS = 0x32 38 | sysIPV6_RTHDR = 0x33 39 | 40 | sysIPV6_RECVTCLASS = 0x39 41 | 42 | sysIPV6_TCLASS = 0x3d 43 | sysIPV6_DONTFRAG = 0x3e 44 | 45 | sysIPV6_PORTRANGE_DEFAULT = 0x0 46 | sysIPV6_PORTRANGE_HIGH = 0x1 47 | sysIPV6_PORTRANGE_LOW = 0x2 48 | 49 | sizeofSockaddrInet6 = 0x1c 50 | sizeofInet6Pktinfo = 0x14 51 | sizeofIPv6Mtuinfo = 0x20 52 | 53 | sizeofIPv6Mreq = 0x14 54 | 55 | sizeofICMPv6Filter = 0x20 56 | ) 57 | 58 | type sockaddrInet6 struct { 59 | Len uint8 60 | Family uint8 61 | Port uint16 62 | Flowinfo uint32 63 | Addr [16]byte /* in6_addr */ 64 | Scope_id uint32 65 | } 66 | 67 | type inet6Pktinfo struct { 68 | Addr [16]byte /* in6_addr */ 69 | Ifindex uint32 70 | } 71 | 72 | type ipv6Mtuinfo struct { 73 | Addr sockaddrInet6 74 | Mtu uint32 75 | } 76 | 77 | type ipv6Mreq struct { 78 | Multiaddr [16]byte /* in6_addr */ 79 | Interface uint32 80 | } 81 | 82 | type icmpv6Filter struct { 83 | Filt [8]uint32 84 | } 85 | --------------------------------------------------------------------------------