mirror of https://github.com/go-gitea/gitea.git
Update caddyserver/certmagic (#16789)
Fixes issue with windows users & letsencrypt Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>pull/16794/head^2
parent
f31e7a67cf
commit
1cd4a3b963
@ -0,0 +1,55 @@
|
||||
// @generated Code generated by gen-atomicwrapper.
|
||||
|
||||
// Copyright (c) 2020-2021 Uber Technologies, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
package atomic
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Time is an atomic type-safe wrapper for time.Time values.
|
||||
type Time struct {
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v Value
|
||||
}
|
||||
|
||||
var _zeroTime time.Time
|
||||
|
||||
// NewTime creates a new Time.
|
||||
func NewTime(val time.Time) *Time {
|
||||
x := &Time{}
|
||||
if val != _zeroTime {
|
||||
x.Store(val)
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
// Load atomically loads the wrapped time.Time.
|
||||
func (x *Time) Load() time.Time {
|
||||
return unpackTime(x.v.Load())
|
||||
}
|
||||
|
||||
// Store atomically stores the passed time.Time.
|
||||
func (x *Time) Store(val time.Time) {
|
||||
x.v.Store(packTime(val))
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2021 Uber Technologies, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
package atomic
|
||||
|
||||
import "time"
|
||||
|
||||
//go:generate bin/gen-atomicwrapper -name=Time -type=time.Time -wrapped=Value -pack=packTime -unpack=unpackTime -imports time -file=time.go
|
||||
|
||||
func packTime(t time.Time) interface{} {
|
||||
return t
|
||||
}
|
||||
|
||||
func unpackTime(v interface{}) time.Time {
|
||||
if t, ok := v.(time.Time); ok {
|
||||
return t
|
||||
}
|
||||
return time.Time{}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package socket
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// ioComplete checks the flags and result of a syscall, to be used as return
|
||||
// value in a syscall.RawConn.Read or Write callback.
|
||||
func ioComplete(flags int, operr error) bool {
|
||||
if flags&syscall.MSG_DONTWAIT != 0 {
|
||||
// Caller explicitly said don't wait, so always return immediately.
|
||||
return true
|
||||
}
|
||||
if operr == syscall.EAGAIN || operr == syscall.EWOULDBLOCK {
|
||||
// No data available, block for I/O and try again.
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build aix || windows || zos
|
||||
// +build aix windows zos
|
||||
|
||||
package socket
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// ioComplete checks the flags and result of a syscall, to be used as return
|
||||
// value in a syscall.RawConn.Read or Write callback.
|
||||
func ioComplete(flags int, operr error) bool {
|
||||
if operr == syscall.EAGAIN || operr == syscall.EWOULDBLOCK {
|
||||
// No data available, block for I/O and try again.
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Helpers for dealing with ifreq since it contains a union and thus requires a
|
||||
// lot of unsafe.Pointer casts to use properly.
|
||||
|
||||
// An Ifreq is a type-safe wrapper around the raw ifreq struct. An Ifreq
|
||||
// contains an interface name and a union of arbitrary data which can be
|
||||
// accessed using the Ifreq's methods. To create an Ifreq, use the NewIfreq
|
||||
// function.
|
||||
//
|
||||
// Use the Name method to access the stored interface name. The union data
|
||||
// fields can be get and set using the following methods:
|
||||
// - Uint16/SetUint16: flags
|
||||
// - Uint32/SetUint32: ifindex, metric, mtu
|
||||
type Ifreq struct{ raw ifreq }
|
||||
|
||||
// NewIfreq creates an Ifreq with the input network interface name after
|
||||
// validating the name does not exceed IFNAMSIZ-1 (trailing NULL required)
|
||||
// bytes.
|
||||
func NewIfreq(name string) (*Ifreq, error) {
|
||||
// Leave room for terminating NULL byte.
|
||||
if len(name) >= IFNAMSIZ {
|
||||
return nil, EINVAL
|
||||
}
|
||||
|
||||
var ifr ifreq
|
||||
copy(ifr.Ifrn[:], name)
|
||||
|
||||
return &Ifreq{raw: ifr}, nil
|
||||
}
|
||||
|
||||
// TODO(mdlayher): get/set methods for hardware address sockaddr, char array, etc.
|
||||
|
||||
// Name returns the interface name associated with the Ifreq.
|
||||
func (ifr *Ifreq) Name() string {
|
||||
// BytePtrToString requires a NULL terminator or the program may crash. If
|
||||
// one is not present, just return the empty string.
|
||||
if !bytes.Contains(ifr.raw.Ifrn[:], []byte{0x00}) {
|
||||
return ""
|
||||
}
|
||||
|
||||
return BytePtrToString(&ifr.raw.Ifrn[0])
|
||||
}
|
||||
|
||||
// According to netdevice(7), only AF_INET addresses are returned for numerous
|
||||
// sockaddr ioctls. For convenience, we expose these as Inet4Addr since the Port
|
||||
// field and other data is always empty.
|
||||
|
||||
// Inet4Addr returns the Ifreq union data from an embedded sockaddr as a C
|
||||
// in_addr/Go []byte (4-byte IPv4 address) value. If the sockaddr family is not
|
||||
// AF_INET, an error is returned.
|
||||
func (ifr *Ifreq) Inet4Addr() ([]byte, error) {
|
||||
raw := *(*RawSockaddrInet4)(unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]))
|
||||
if raw.Family != AF_INET {
|
||||
// Cannot safely interpret raw.Addr bytes as an IPv4 address.
|
||||
return nil, EINVAL
|
||||
}
|
||||
|
||||
return raw.Addr[:], nil
|
||||
}
|
||||
|
||||
// SetInet4Addr sets a C in_addr/Go []byte (4-byte IPv4 address) value in an
|
||||
// embedded sockaddr within the Ifreq's union data. v must be 4 bytes in length
|
||||
// or an error will be returned.
|
||||
func (ifr *Ifreq) SetInet4Addr(v []byte) error {
|
||||
if len(v) != 4 {
|
||||
return EINVAL
|
||||
}
|
||||
|
||||
var addr [4]byte
|
||||
copy(addr[:], v)
|
||||
|
||||
ifr.clear()
|
||||
*(*RawSockaddrInet4)(
|
||||
unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]),
|
||||
) = RawSockaddrInet4{
|
||||
// Always set IP family as ioctls would require it anyway.
|
||||
Family: AF_INET,
|
||||
Addr: addr,
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Uint16 returns the Ifreq union data as a C short/Go uint16 value.
|
||||
func (ifr *Ifreq) Uint16() uint16 {
|
||||
return *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0]))
|
||||
}
|
||||
|
||||
// SetUint16 sets a C short/Go uint16 value as the Ifreq's union data.
|
||||
func (ifr *Ifreq) SetUint16(v uint16) {
|
||||
ifr.clear()
|
||||
*(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0])) = v
|
||||
}
|
||||
|
||||
// Uint32 returns the Ifreq union data as a C int/Go uint32 value.
|
||||
func (ifr *Ifreq) Uint32() uint32 {
|
||||
return *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0]))
|
||||
}
|
||||
|
||||
// SetUint32 sets a C int/Go uint32 value as the Ifreq's union data.
|
||||
func (ifr *Ifreq) SetUint32(v uint32) {
|
||||
ifr.clear()
|
||||
*(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0])) = v
|
||||
}
|
||||
|
||||
// clear zeroes the ifreq's union field to prevent trailing garbage data from
|
||||
// being sent to the kernel if an ifreq is reused.
|
||||
func (ifr *Ifreq) clear() {
|
||||
for i := range ifr.raw.Ifru {
|
||||
ifr.raw.Ifru[i] = 0
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
|
||||
// IoctlGetEthtoolDrvinfo which use these APIs under the hood.
|
||||
|
||||
// An ifreqData is an Ifreq which carries pointer data. To produce an ifreqData,
|
||||
// use the Ifreq.withData method.
|
||||
type ifreqData struct {
|
||||
name [IFNAMSIZ]byte
|
||||
// A type separate from ifreq is required in order to comply with the
|
||||
// unsafe.Pointer rules since the "pointer-ness" of data would not be
|
||||
// preserved if it were cast into the byte array of a raw ifreq.
|
||||
data unsafe.Pointer
|
||||
// Pad to the same size as ifreq.
|
||||
_ [len(ifreq{}.Ifru) - SizeofPtr]byte
|
||||
}
|
||||
|
||||
// withData produces an ifreqData with the pointer p set for ioctls which require
|
||||
// arbitrary pointer data.
|
||||
func (ifr Ifreq) withData(p unsafe.Pointer) ifreqData {
|
||||
return ifreqData{
|
||||
name: ifr.raw.Ifrn,
|
||||
data: p,
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue