Use certmagic, simplify config, set HTTP timeouts and a modern TLSConfig

This commit is contained in:
Ken-Håvard Lieng 2018-12-16 12:19:16 +01:00
parent c5a9a5b1c1
commit 6c3a5777c4
171 changed files with 30701 additions and 4912 deletions

View file

@ -8,17 +8,30 @@
package unix
import "unsafe"
import (
"runtime"
"unsafe"
)
// Round the length of a raw sockaddr up to align it properly.
func cmsgAlignOf(salen int) int {
salign := SizeofPtr
// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
// Solaris kernels still require 32-bit aligned access to
// network subsystem.
if darwin64Bit || dragonfly64Bit || solaris64Bit {
salign = 4
switch runtime.GOOS {
case "darwin", "dragonfly", "solaris":
// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
// Solaris kernels still require 32-bit aligned access to
// network subsystem.
if SizeofPtr == 8 {
salign = 4
}
case "openbsd":
// OpenBSD armv7 requires 64-bit alignment.
if runtime.GOARCH == "arm" {
salign = 8
}
}
return (salen + salign - 1) & ^(salign - 1)
}

View file

@ -13,10 +13,7 @@
package unix
import (
"syscall"
"unsafe"
)
import "unsafe"
/*
* Wrapped
@ -385,10 +382,6 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
func Flock(fd int, how int) (err error) {
return syscall.Flock(fd, how)
}
/*
* Direct access
*/

View file

@ -1503,15 +1503,12 @@ func Munmap(b []byte) (err error) {
// Vmsplice splices user pages from a slice of Iovecs into a pipe specified by fd,
// using the specified flags.
func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) {
n, _, errno := Syscall6(
SYS_VMSPLICE,
uintptr(fd),
uintptr(unsafe.Pointer(&iovs[0])),
uintptr(len(iovs)),
uintptr(flags),
0,
0,
)
var p unsafe.Pointer
if len(iovs) > 0 {
p = unsafe.Pointer(&iovs[0])
}
n, _, errno := Syscall6(SYS_VMSPLICE, uintptr(fd), uintptr(p), uintptr(len(iovs)), uintptr(flags), 0, 0)
if errno != 0 {
return 0, syscall.Errno(errno)
}

View file

@ -20,12 +20,26 @@ package unix
//sysnb Getgid() (gid int)
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
//sysnb Getuid() (uid int)
//sysnb InotifyInit() (fd int, err error)
//sysnb inotifyInit() (fd int, err error)
func InotifyInit() (fd int, err error) {
// First try inotify_init1, because Android's seccomp policy blocks the latter.
fd, err = InotifyInit1(0)
if err == ENOSYS {
fd, err = inotifyInit()
}
return
}
//sys Ioperm(from int, num int, on int) (err error)
//sys Iopl(level int) (err error)
//sys Lchown(path string, uid int, gid int) (err error)
//sys Listen(s int, n int) (err error)
//sys Lstat(path string, stat *Stat_t) (err error)
func Lstat(path string, stat *Stat_t) (err error) {
return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
}
//sys Pause() (err error)
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64

View file

@ -257,3 +257,11 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
}
return poll(&fds[0], len(fds), timeout)
}
//sys armSyncFileRange(fd int, flags int, off int64, n int64) (err error) = SYS_ARM_SYNC_FILE_RANGE
func SyncFileRange(fd int, off int64, n int64, flags int) error {
// The sync_file_range and arm_sync_file_range syscalls differ only in the
// order of their arguments.
return armSyncFileRange(fd, flags, off, n)
}

View file

@ -8,7 +8,6 @@ package unix
import (
"bytes"
"runtime"
"sort"
"sync"
"syscall"
@ -21,13 +20,6 @@ var (
Stderr = 2
)
const (
darwin64Bit = runtime.GOOS == "darwin" && SizeofPtr == 8
dragonfly64Bit = runtime.GOOS == "dragonfly" && SizeofPtr == 8
netbsd32Bit = runtime.GOOS == "netbsd" && SizeofPtr == 4
solaris64Bit = runtime.GOOS == "solaris" && SizeofPtr == 8
)
// Do the interface allocations only once for common
// Errno values.
var (

View file

@ -1806,7 +1806,7 @@ func Getuid() (uid int) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func InotifyInit() (fd int, err error) {
func inotifyInit() (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
fd = int(r0)
if e1 != 0 {
@ -1862,21 +1862,6 @@ func Listen(s int, n int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lstat(path string, stat *Stat_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pause() (err error) {
_, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
if e1 != 0 {

View file

@ -2282,3 +2282,13 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func armSyncFileRange(fd int, flags int, off int64, n int64) (err error) {
_, _, e1 := Syscall6(SYS_ARM_SYNC_FILE_RANGE, uintptr(fd), uintptr(flags), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32))
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View file

@ -1,4 +1,4 @@
// cgo -godefs types_openbsd.go | go run mkpost.go
// cgo -godefs -- -fsigned-char types_openbsd.go | go run mkpost.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build arm,openbsd
@ -23,11 +23,13 @@ type (
type Timespec struct {
Sec int64
Nsec int32
_ [4]byte
}
type Timeval struct {
Sec int64
Usec int32
_ [4]byte
}
type Rusage struct {
@ -57,28 +59,30 @@ type Rlimit struct {
type _Gid_t uint32
type Stat_t struct {
Mode uint32
Dev int32
Ino uint64
Nlink uint32
Uid uint32
Gid uint32
Rdev int32
Atim Timespec
Mtim Timespec
Ctim Timespec
Size int64
Blocks int64
Blksize int32
Flags uint32
Gen uint32
X__st_birthtim Timespec
Mode uint32
Dev int32
Ino uint64
Nlink uint32
Uid uint32
Gid uint32
Rdev int32
Atim Timespec
Mtim Timespec
Ctim Timespec
Size int64
Blocks int64
Blksize int32
Flags uint32
Gen uint32
_ [4]byte
_ Timespec
}
type Statfs_t struct {
F_flags uint32
F_bsize uint32
F_iosize uint32
_ [4]byte
F_blocks uint64
F_bfree uint64
F_bavail int64
@ -93,11 +97,11 @@ type Statfs_t struct {
F_namemax uint32
F_owner uint32
F_ctime uint64
F_fstypename [16]uint8
F_mntonname [90]uint8
F_mntfromname [90]uint8
F_mntfromspec [90]uint8
Pad_cgo_0 [2]byte
F_fstypename [16]int8
F_mntonname [90]int8
F_mntfromname [90]int8
F_mntfromspec [90]int8
_ [2]byte
Mount_info [160]byte
}
@ -110,13 +114,13 @@ type Flock_t struct {
}
type Dirent struct {
Fileno uint64
Off int64
Reclen uint16
Type uint8
Namlen uint8
X__d_padding [4]uint8
Name [256]uint8
Fileno uint64
Off int64
Reclen uint16
Type uint8
Namlen uint8
_ [4]uint8
Name [256]int8
}
type Fsid struct {
@ -251,8 +255,10 @@ type Kevent_t struct {
Filter int16
Flags uint16
Fflags uint32
_ [4]byte
Data int64
Udata *byte
_ [4]byte
}
type FdSet struct {
@ -260,8 +266,8 @@ type FdSet struct {
}
const (
SizeofIfMsghdr = 0x98
SizeofIfData = 0x80
SizeofIfMsghdr = 0xa8
SizeofIfData = 0x90
SizeofIfaMsghdr = 0x18
SizeofIfAnnounceMsghdr = 0x1a
SizeofRtMsghdr = 0x60
@ -290,7 +296,7 @@ type IfData struct {
Link_state uint8
Mtu uint32
Metric uint32
Pad uint32
Rdomain uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
@ -302,8 +308,10 @@ type IfData struct {
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Oqdrops uint64
Noproto uint64
Capabilities uint32
_ [4]byte
Lastchange Timeval
}
@ -328,7 +336,7 @@ type IfAnnounceMsghdr struct {
Hdrlen uint16
Index uint16
What uint16
Name [16]uint8
Name [16]int8
}
type RtMsghdr struct {
@ -398,11 +406,11 @@ type BpfInsn struct {
}
type BpfHdr struct {
Tstamp BpfTimeval
Caplen uint32
Datalen uint32
Hdrlen uint16
Pad_cgo_0 [2]byte
Tstamp BpfTimeval
Caplen uint32
Datalen uint32
Hdrlen uint16
_ [2]byte
}
type BpfTimeval struct {
@ -476,7 +484,7 @@ type Uvmexp struct {
Zeropages int32
Reserve_pagedaemon int32
Reserve_kernel int32
Anonpages int32
Unused01 int32
Vnodepages int32
Vtextpages int32
Freemin int32
@ -495,8 +503,8 @@ type Uvmexp struct {
Swpgonly int32
Nswget int32
Nanon int32
Nanonneeded int32
Nfreeanon int32
Unused05 int32
Unused06 int32
Faults int32
Traps int32
Intrs int32
@ -504,8 +512,8 @@ type Uvmexp struct {
Softs int32
Syscalls int32
Pageins int32
Obsolete_swapins int32
Obsolete_swapouts int32
Unused07 int32
Unused08 int32
Pgswapin int32
Pgswapout int32
Forks int32
@ -513,7 +521,7 @@ type Uvmexp struct {
Forks_sharevm int32
Pga_zerohit int32
Pga_zeromiss int32
Zeroaborts int32
Unused09 int32
Fltnoram int32
Fltnoanon int32
Fltnoamap int32
@ -545,9 +553,9 @@ type Uvmexp struct {
Pdpageouts int32
Pdpending int32
Pddeact int32
Pdreanon int32
Pdrevnode int32
Pdrevtext int32
Unused11 int32
Unused12 int32
Unused13 int32
Fpswtch int32
Kmapent int32
}