Use Goodbye to handle DB close on exit
This commit is contained in:
parent
739a3f2bdb
commit
657bed599c
|
@ -17,7 +17,7 @@
|
|||
branch = "master"
|
||||
name = "github.com/dustin/go-humanize"
|
||||
packages = ["."]
|
||||
revision = "79e699ccd02f240a1f1fbbdcee7e64c1c12e41aa"
|
||||
revision = "77ed807830b4df581417e7f89eb81d4872832b72"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -49,21 +49,27 @@
|
|||
packages = ["."]
|
||||
revision = "0362cd091b6b627bf9552d87ba15956d5e8bde32"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/thecodeteam/goodbye"
|
||||
packages = ["."]
|
||||
revision = "a83968bda2d37294a3541b7d2207fb6f5a3559a3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = ["proxy"]
|
||||
revision = "0a9397675ba34b2845f758fe3cd68828369c6517"
|
||||
revision = "a04bdaca5b32abe1c069418fb7088ae607de5bd0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
revision = "314a259e304ff91bd6985da2a7149bbf91237993"
|
||||
revision = "43eea11bc92608addb41b8a406b0407495c106f6"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "3ede8cd77942973b25c138dff8b4cf67d09b480442ffe164b6ede377d0f28d06"
|
||||
inputs-digest = "9c816225227b0ce468b9f2438dc8e60932e6b037ead9708c5f8c980ae33cf8c3"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
24
sage.go
24
sage.go
|
@ -19,6 +19,7 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
@ -26,18 +27,17 @@ import (
|
|||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/dustin/go-humanize"
|
||||
irc "github.com/fluffle/goirc/client"
|
||||
"github.com/mandykoh/markov"
|
||||
"github.com/thecodeteam/goodbye"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
@ -281,11 +281,6 @@ func saveMemories() {
|
|||
}
|
||||
}
|
||||
|
||||
func terminate() {
|
||||
self.Close()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
@ -354,12 +349,13 @@ func main() {
|
|||
quit <- true
|
||||
})
|
||||
|
||||
termc := make(chan os.Signal, 2)
|
||||
signal.Notify(termc, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-termc
|
||||
terminate()
|
||||
}()
|
||||
ctx := context.Background()
|
||||
defer goodbye.Exit(ctx, -1)
|
||||
goodbye.Notify(ctx)
|
||||
|
||||
goodbye.Register(func(ctx context.Context, sig os.Signal) {
|
||||
self.Close()
|
||||
})
|
||||
|
||||
for {
|
||||
log.Printf("Connecting to %s as %s...", config.Server, config.Nick)
|
||||
|
@ -371,6 +367,4 @@ func main() {
|
|||
log.Println("Disconnected...")
|
||||
time.Sleep(30 * time.Second)
|
||||
}
|
||||
|
||||
terminate()
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#*
|
||||
*.[568]
|
||||
*.a
|
||||
*~
|
||||
[568].out
|
||||
_*
|
|
@ -0,0 +1,17 @@
|
|||
/example/example
|
||||
/example/example.exe
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||
.glide/
|
|
@ -0,0 +1,16 @@
|
|||
# Setting "sudo" to false forces Travis-CI to use its
|
||||
# container-based build infrastructure, which has shorter
|
||||
# queue times.
|
||||
sudo: false
|
||||
|
||||
# Use the newer Travis-CI build templates based on the
|
||||
# Debian Linux distribution "Trusty" release.
|
||||
dist: trusty
|
||||
|
||||
# Select Go as the language used to run the buid.
|
||||
language: go
|
||||
go: 1.8.3
|
||||
go_import_path: github.com/thecodeteam/goodbye
|
||||
|
||||
install: true
|
||||
script: go test -v .
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,113 @@
|
|||
# Goodbye
|
||||
Goodbye is a Golang library that provides a standard way to execute code
|
||||
when a process exits normally or due to a signal.
|
||||
|
||||
## Overview
|
||||
The Goodbye library uses a `sync.Once` to ensure that the registered exit
|
||||
handlers are executed only once -- whether as a result of the process exiting
|
||||
normally or as a result of a received signal.
|
||||
|
||||
## Install
|
||||
Say hello to goodbye with `go get github.com/thecodeteam/goodbye`.
|
||||
|
||||
## Example
|
||||
There is an [`example`](./example/example.go) program that illustrates
|
||||
how to use the Goodbye library:
|
||||
|
||||
```golang
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/thecodeteam/goodbye"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create a context to use with the Goodbye library's functions.
|
||||
ctx := context.Background()
|
||||
|
||||
// Always defer `goodbye.Exit` as early as possible since it is
|
||||
// safe to execute no matter what.
|
||||
defer goodbye.Exit(ctx, -1)
|
||||
|
||||
// Invoke `goodbye.Notify` to begin trapping signals this process
|
||||
// might receive. The Notify function can specify which signals are
|
||||
// trapped, but if none are specified then a default list is used.
|
||||
// The default set is platform dependent. See the files
|
||||
// "goodbye_GOOS.go" for more information.
|
||||
goodbye.Notify(ctx)
|
||||
|
||||
// Register two functions that will be executed when this process
|
||||
// exits.
|
||||
goodbye.Register(func(ctx context.Context, sig os.Signal) {
|
||||
fmt.Printf("1: %[1]d: %[1]s\n", sig)
|
||||
})
|
||||
|
||||
goodbye.Register(func(ctx context.Context, sig os.Signal) {
|
||||
fmt.Printf("2: %[1]d: %[1]s\n", sig)
|
||||
})
|
||||
|
||||
// Register a function with a priority that is higher than the two
|
||||
// handlers above. Since the default priority is 0, a priority of -1
|
||||
// will ensure this function, registered last, is executed first.
|
||||
goodbye.RegisterWithPriority(func(ctx context.Context, sig os.Signal) {
|
||||
|
||||
// Use the `goodbye.IsNormalExit` function in conjunction with
|
||||
// the signal to determine if this is a signal-based exit. If it
|
||||
// is then emit a leading newline character to place the desired
|
||||
// text on a line after the `CTRL-C` if that was used to send
|
||||
// SIGINT to the process.
|
||||
//
|
||||
// Note that the extra text is being printed inside the second,
|
||||
// registered handler. This is because handlers are executed in
|
||||
// reverse order -- the earlier a handler is registered, the later
|
||||
// it is executed.
|
||||
if !goodbye.IsNormalExit(sig) {
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
fmt.Printf("0: %[1]d: %[1]s\n", sig)
|
||||
}, -1)
|
||||
|
||||
if len(os.Args) < 2 {
|
||||
return
|
||||
}
|
||||
|
||||
// If the program's first argument is "wait" then block until the
|
||||
// program is killed with a signal -- either from the "kill" command
|
||||
// or a CTRL-C.
|
||||
if strings.EqualFold("wait", os.Args[1]) {
|
||||
c := make(chan int)
|
||||
<-c
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Example 1
|
||||
This example shows how the exit handlers are invoked when the program
|
||||
exits normally.
|
||||
|
||||
```bash
|
||||
$ go run example/example.go
|
||||
0: 0: nosig
|
||||
1: 0: nosig
|
||||
2: 0: nosig
|
||||
```
|
||||
|
||||
Please note that the first registered exit handler was executed last.
|
||||
|
||||
### Example 2
|
||||
This example shows how the exit handlers are executed when a signal is
|
||||
received:
|
||||
|
||||
```bash
|
||||
$ go run example/example.go wait
|
||||
^C
|
||||
0: 2: interrupt
|
||||
1: 2: interrupt
|
||||
2: 2: interrupt
|
||||
```
|
|
@ -0,0 +1 @@
|
|||
0.1.0
|
|
@ -0,0 +1,70 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/thecodeteam/goodbye"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create a context to use with the Goodbye library's functions.
|
||||
ctx := context.Background()
|
||||
|
||||
// Always defer `goodbye.Exit` as early as possible since it is
|
||||
// safe to execute no matter what.
|
||||
defer goodbye.Exit(ctx, -1)
|
||||
|
||||
// Invoke `goodbye.Notify` to begin trapping signals this process
|
||||
// might receive. The Notify function can specify which signals are
|
||||
// trapped, but if none are specified then a default list is used.
|
||||
// The default set is platform dependent. See the files
|
||||
// "goodbye_GOOS.go" for more information.
|
||||
goodbye.Notify(ctx)
|
||||
|
||||
// Register two functions that will be executed when this process
|
||||
// exits.
|
||||
goodbye.Register(func(ctx context.Context, sig os.Signal) {
|
||||
fmt.Printf("1: %[1]d: %[1]s\n", sig)
|
||||
})
|
||||
|
||||
goodbye.Register(func(ctx context.Context, sig os.Signal) {
|
||||
fmt.Printf("2: %[1]d: %[1]s\n", sig)
|
||||
})
|
||||
|
||||
// Register a function with a priority that is higher than the two
|
||||
// handlers above. Since the default priority is 0, a priority of -1
|
||||
// will ensure this function, registered last, is executed first.
|
||||
goodbye.RegisterWithPriority(func(ctx context.Context, sig os.Signal) {
|
||||
|
||||
// Use the `goodbye.IsNormalExit` function in conjunction with
|
||||
// the signal to determine if this is a signal-based exit. If it
|
||||
// is then emit a leading newline character to place the desired
|
||||
// text on a line after the `CTRL-C` if that was used to send
|
||||
// SIGINT to the process.
|
||||
//
|
||||
// Note that the extra text is being printed inside the second,
|
||||
// registered handler. This is because handlers are executed in
|
||||
// reverse order -- the earlier a handler is registered, the later
|
||||
// it is executed.
|
||||
if !goodbye.IsNormalExit(sig) {
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
fmt.Printf("0: %[1]d: %[1]s\n", sig)
|
||||
}, -1)
|
||||
|
||||
if len(os.Args) < 2 {
|
||||
return
|
||||
}
|
||||
|
||||
// If the program's first argument is "wait" then block until the
|
||||
// program is killed with a signal -- either from the "kill" command
|
||||
// or a CTRL-C.
|
||||
if strings.EqualFold("wait", os.Args[1]) {
|
||||
c := make(chan int)
|
||||
<-c
|
||||
}
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
// +build go1.8
|
||||
|
||||
package goodbye
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// ExitHandler is a function that is registerd with the "Register" function
|
||||
// and is invoked when this process exits, either normally or due to a process
|
||||
// signal.
|
||||
type ExitHandler func(ctx context.Context, s os.Signal)
|
||||
|
||||
type noSig struct {
|
||||
}
|
||||
|
||||
func (s noSig) String() string {
|
||||
return "nosig"
|
||||
}
|
||||
func (s noSig) Signal() {
|
||||
}
|
||||
func (s noSig) Format(f fmt.State, c rune) {
|
||||
val := s.String()
|
||||
if c == 'd' {
|
||||
val = "0"
|
||||
}
|
||||
f.Write([]byte(val))
|
||||
}
|
||||
|
||||
var (
|
||||
// ExitCode is the exit code used by the Exit function if it is called
|
||||
// with an exit code value of -1.
|
||||
ExitCode int
|
||||
|
||||
// handlers is a list of exit handlers to invoke when the process exits
|
||||
// or receives a signal that causes an exit behavior
|
||||
handlers = map[int][]ExitHandler{}
|
||||
handlersRWL sync.RWMutex
|
||||
|
||||
// noSigVal is provided to the handleOnce function when Exit is invoked
|
||||
// so that exit handlers can use the IsNormalExit function to determine
|
||||
// if the process is exiting normally or due to a process signal.
|
||||
noSigVal noSig
|
||||
|
||||
// defaultSignals is the default list of signals and exit codes to use
|
||||
// if the Notify function is invoked with an empty signals argument value
|
||||
defaultSignals map[os.Signal]int
|
||||
|
||||
// notified is the list of signals that are trapped as a result of the
|
||||
// Notify function. This list is what the Reset function uses when undoing
|
||||
// the effects of the Notify function.
|
||||
notified []os.Signal
|
||||
|
||||
// once is used by the handleOnce function to execute the exit handlers
|
||||
// and os.Exit exactly once, regardless of how many times Exit is invoked
|
||||
// or if a signal is received at the same time that Exit is invoked
|
||||
once sync.Once
|
||||
|
||||
// lock is used to prevent the Exit, Notify, and Reset functions
|
||||
// from being called concurrently.
|
||||
lock sync.Mutex
|
||||
)
|
||||
|
||||
// Register registers a function to be invoked when this process exits
|
||||
// normally or due to a process signal.
|
||||
//
|
||||
// Handlers registered with this function are given a priority of 0.
|
||||
func Register(f ExitHandler) {
|
||||
RegisterWithPriority(f, 0)
|
||||
}
|
||||
|
||||
// RegisterWithPriority registers a function to be invoked when
|
||||
// this process exits normally or due to a process signal.
|
||||
//
|
||||
// The priority determines when an exit handler is executed. Handlers
|
||||
// with a lower integer value execute first and higher integer values
|
||||
// execute later. If multiple handlers share the same priority level
|
||||
// then the handlers are invoked in the order in which they were
|
||||
// registered.
|
||||
func RegisterWithPriority(f ExitHandler, priority int) {
|
||||
handlersRWL.Lock()
|
||||
defer handlersRWL.Unlock()
|
||||
if a, ok := handlers[priority]; !ok {
|
||||
handlers[priority] = []ExitHandler{f}
|
||||
} else {
|
||||
handlers[priority] = append(a, f)
|
||||
}
|
||||
}
|
||||
|
||||
// IsNormalExit returns true if the program is exiting as a result of
|
||||
// the Exit function being invoked versus a process signal.
|
||||
func IsNormalExit(sig os.Signal) bool {
|
||||
return sig == noSigVal
|
||||
}
|
||||
|
||||
// Exit executes all of the registered exit handlers.
|
||||
//
|
||||
// The handlers may use the IsNormalExit function and the signal provided
|
||||
// to the handler to check if the program is exiting normally or due to
|
||||
// a process signal.
|
||||
func Exit(ctx context.Context, exitCode int) {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
if exitCode < 0 {
|
||||
exitCode = ExitCode
|
||||
}
|
||||
handleOnce(ctx, noSigVal, exitCode)
|
||||
}
|
||||
|
||||
// Notify begins trapping the specified signals. This function should be
|
||||
// invoked as early as possible by the executing program.
|
||||
//
|
||||
// The signals argument accepts a series of os.Signal values. Any os.Signal
|
||||
// value in the list may be succeeded with an integer to be used as the
|
||||
// process's exit code when the associated signal is received. By default
|
||||
// the process will exit with an exit code of zero, indicating a graceful
|
||||
// shutdown.
|
||||
//
|
||||
// The default value for the signals variadic depends on the operating
|
||||
// system (OS):
|
||||
//
|
||||
// UNIX
|
||||
// SIGKILL, 1, SIGHUP, 0, SIGINT, 0, SIGQUIT, 0, SIGTERM, 0
|
||||
//
|
||||
// Windows
|
||||
// SIGKILL, 1, SIGHUP, 0, os.Interrupt, 0, SIGQUIT, 0, SIGTERM, 0
|
||||
func Notify(ctx context.Context, signals ...interface{}) {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
|
||||
var sigs map[os.Signal]int
|
||||
if len(signals) == 0 {
|
||||
sigs = defaultSignals
|
||||
} else {
|
||||
sigs = map[os.Signal]int{}
|
||||
var s os.Signal
|
||||
for _, v := range signals {
|
||||
switch tv := v.(type) {
|
||||
case os.Signal:
|
||||
s = tv
|
||||
sigs[s] = 0
|
||||
case int:
|
||||
sigs[s] = tv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
i = 0
|
||||
sigc = make(chan os.Signal, 1)
|
||||
notified = make([]os.Signal, len(sigs))
|
||||
)
|
||||
for s := range sigs {
|
||||
notified[i] = s
|
||||
i++
|
||||
}
|
||||
|
||||
signal.Notify(sigc, notified...)
|
||||
|
||||
go func() {
|
||||
for s := range sigc {
|
||||
|
||||
// Get the exit code associated with the signal. If no
|
||||
// exit code exists then the signal was not trapped and
|
||||
// should not be handled.
|
||||
x, ok := sigs[s]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Execute the signal handlers and exit the program.
|
||||
handleOnce(ctx, s, x)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Reset clears the list of registered exit handlers and stops trapping
|
||||
// the signals that were trapped as a result of the Notify function.
|
||||
func Reset() {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
signal.Reset(notified...)
|
||||
|
||||
handlersRWL.Lock()
|
||||
defer handlersRWL.Unlock()
|
||||
handlers = nil
|
||||
}
|
||||
|
||||
func handleOnce(ctx context.Context, s os.Signal, x int) {
|
||||
once.Do(func() {
|
||||
handle(ctx, s)
|
||||
os.Exit(x)
|
||||
})
|
||||
}
|
||||
|
||||
func handle(ctx context.Context, s os.Signal) {
|
||||
handlersRWL.RLock()
|
||||
defer handlersRWL.RUnlock()
|
||||
|
||||
keys := []int{}
|
||||
for k := range handlers {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
sort.Ints(keys)
|
||||
|
||||
for _, k := range keys {
|
||||
for _, h := range handlers[k] {
|
||||
h(ctx, s)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
/*
|
||||
Package goodbye provides a standard way to execute code when a process
|
||||
exits normally or due to a signal.
|
||||
*/
|
||||
package goodbye
|
|
@ -0,0 +1,18 @@
|
|||
// +build !windows
|
||||
|
||||
package goodbye
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func init() {
|
||||
defaultSignals = map[os.Signal]int{
|
||||
syscall.SIGKILL: 1,
|
||||
syscall.SIGHUP: 0,
|
||||
syscall.SIGINT: 0,
|
||||
syscall.SIGQUIT: 0,
|
||||
syscall.SIGTERM: 0,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// +build windows
|
||||
|
||||
package goodbye
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func init() {
|
||||
defaultSignals = map[os.Signal]int{
|
||||
syscall.SIGKILL: 1,
|
||||
syscall.SIGHUP: 0,
|
||||
os.Interrupt: 0,
|
||||
syscall.SIGQUIT: 0,
|
||||
syscall.SIGTERM: 0,
|
||||
}
|
||||
}
|
|
@ -10,6 +10,10 @@ package socket
|
|||
import "unsafe"
|
||||
|
||||
func (v *iovec) set(b []byte) {
|
||||
l := len(b)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
v.Base = (*byte)(unsafe.Pointer(&b[0]))
|
||||
v.Len = uint32(len(b))
|
||||
v.Len = uint32(l)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ package socket
|
|||
import "unsafe"
|
||||
|
||||
func (v *iovec) set(b []byte) {
|
||||
l := len(b)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
v.Base = (*byte)(unsafe.Pointer(&b[0]))
|
||||
v.Len = uint64(len(b))
|
||||
v.Len = uint64(l)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ package socket
|
|||
import "unsafe"
|
||||
|
||||
func (v *iovec) set(b []byte) {
|
||||
l := len(b)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
v.Base = (*int8)(unsafe.Pointer(&b[0]))
|
||||
v.Len = uint64(len(b))
|
||||
v.Len = uint64(l)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
package socket
|
||||
|
||||
func (h *msghdr) setIov(vs []iovec) {
|
||||
l := len(vs)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
h.Iov = &vs[0]
|
||||
h.Iovlen = int32(len(vs))
|
||||
h.Iovlen = int32(l)
|
||||
}
|
||||
|
|
|
@ -10,8 +10,12 @@ package socket
|
|||
import "unsafe"
|
||||
|
||||
func (h *msghdr) setIov(vs []iovec) {
|
||||
l := len(vs)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
h.Iov = &vs[0]
|
||||
h.Iovlen = uint32(len(vs))
|
||||
h.Iovlen = uint32(l)
|
||||
}
|
||||
|
||||
func (h *msghdr) setControl(b []byte) {
|
||||
|
|
|
@ -10,8 +10,12 @@ package socket
|
|||
import "unsafe"
|
||||
|
||||
func (h *msghdr) setIov(vs []iovec) {
|
||||
l := len(vs)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
h.Iov = &vs[0]
|
||||
h.Iovlen = uint64(len(vs))
|
||||
h.Iovlen = uint64(l)
|
||||
}
|
||||
|
||||
func (h *msghdr) setControl(b []byte) {
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
package socket
|
||||
|
||||
func (h *msghdr) setIov(vs []iovec) {
|
||||
l := len(vs)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
h.Iov = &vs[0]
|
||||
h.Iovlen = uint32(len(vs))
|
||||
h.Iovlen = uint32(l)
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) {
|
|||
for i := range vs {
|
||||
vs[i].set(bs[i])
|
||||
}
|
||||
h.Iov = &vs[0]
|
||||
h.Iovlen = int32(len(vs))
|
||||
if len(vs) > 0 {
|
||||
h.Iov = &vs[0]
|
||||
h.Iovlen = int32(len(vs))
|
||||
}
|
||||
if len(oob) > 0 {
|
||||
h.Accrights = (*int8)(unsafe.Pointer(&oob[0]))
|
||||
h.Accrightslen = int32(len(oob))
|
||||
|
|
|
@ -119,81 +119,84 @@ func TestUDP(t *testing.T) {
|
|||
t.Skipf("not supported on %s/%s: %v", runtime.GOOS, runtime.GOARCH, err)
|
||||
}
|
||||
defer c.Close()
|
||||
cc, err := socket.NewConn(c.(net.Conn))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Run("Message", func(t *testing.T) {
|
||||
testUDPMessage(t, c.(net.Conn))
|
||||
data := []byte("HELLO-R-U-THERE")
|
||||
wm := socket.Message{
|
||||
Buffers: bytes.SplitAfter(data, []byte("-")),
|
||||
Addr: c.LocalAddr(),
|
||||
}
|
||||
if err := cc.SendMsg(&wm, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b := make([]byte, 32)
|
||||
rm := socket.Message{
|
||||
Buffers: [][]byte{b[:1], b[1:3], b[3:7], b[7:11], b[11:]},
|
||||
}
|
||||
if err := cc.RecvMsg(&rm, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(b[:rm.N], data) {
|
||||
t.Fatalf("got %#v; want %#v", b[:rm.N], data)
|
||||
}
|
||||
})
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
case "android", "linux":
|
||||
t.Run("Messages", func(t *testing.T) {
|
||||
testUDPMessages(t, c.(net.Conn))
|
||||
data := []byte("HELLO-R-U-THERE")
|
||||
wmbs := bytes.SplitAfter(data, []byte("-"))
|
||||
wms := []socket.Message{
|
||||
{Buffers: wmbs[:1], Addr: c.LocalAddr()},
|
||||
{Buffers: wmbs[1:], Addr: c.LocalAddr()},
|
||||
}
|
||||
n, err := cc.SendMsgs(wms, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n != len(wms) {
|
||||
t.Fatalf("got %d; want %d", n, len(wms))
|
||||
}
|
||||
b := make([]byte, 32)
|
||||
rmbs := [][][]byte{{b[:len(wmbs[0])]}, {b[len(wmbs[0]):]}}
|
||||
rms := []socket.Message{
|
||||
{Buffers: rmbs[0]},
|
||||
{Buffers: rmbs[1]},
|
||||
}
|
||||
n, err = cc.RecvMsgs(rms, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n != len(rms) {
|
||||
t.Fatalf("got %d; want %d", n, len(rms))
|
||||
}
|
||||
nn := 0
|
||||
for i := 0; i < n; i++ {
|
||||
nn += rms[i].N
|
||||
}
|
||||
if !bytes.Equal(b[:nn], data) {
|
||||
t.Fatalf("got %#v; want %#v", b[:nn], data)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testUDPMessage(t *testing.T, c net.Conn) {
|
||||
cc, err := socket.NewConn(c)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data := []byte("HELLO-R-U-THERE")
|
||||
// The behavior of transmission for zero byte paylaod depends
|
||||
// on each platform implementation. Some may transmit only
|
||||
// protocol header and options, other may transmit nothing.
|
||||
// We test only that SendMsg and SendMsgs will not crash with
|
||||
// empty buffers.
|
||||
wm := socket.Message{
|
||||
Buffers: bytes.SplitAfter(data, []byte("-")),
|
||||
Buffers: [][]byte{{}},
|
||||
Addr: c.LocalAddr(),
|
||||
}
|
||||
if err := cc.SendMsg(&wm, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b := make([]byte, 32)
|
||||
rm := socket.Message{
|
||||
Buffers: [][]byte{b[:1], b[1:3], b[3:7], b[7:11], b[11:]},
|
||||
}
|
||||
if err := cc.RecvMsg(&rm, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(b[:rm.N], data) {
|
||||
t.Fatalf("got %#v; want %#v", b[:rm.N], data)
|
||||
}
|
||||
}
|
||||
|
||||
func testUDPMessages(t *testing.T, c net.Conn) {
|
||||
cc, err := socket.NewConn(c)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data := []byte("HELLO-R-U-THERE")
|
||||
wmbs := bytes.SplitAfter(data, []byte("-"))
|
||||
cc.SendMsg(&wm, 0)
|
||||
wms := []socket.Message{
|
||||
{Buffers: wmbs[:1], Addr: c.LocalAddr()},
|
||||
{Buffers: wmbs[1:], Addr: c.LocalAddr()},
|
||||
}
|
||||
n, err := cc.SendMsgs(wms, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n != len(wms) {
|
||||
t.Fatalf("got %d; want %d", n, len(wms))
|
||||
}
|
||||
b := make([]byte, 32)
|
||||
rmbs := [][][]byte{{b[:len(wmbs[0])]}, {b[len(wmbs[0]):]}}
|
||||
rms := []socket.Message{
|
||||
{Buffers: rmbs[0]},
|
||||
{Buffers: rmbs[1]},
|
||||
}
|
||||
n, err = cc.RecvMsgs(rms, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n != len(rms) {
|
||||
t.Fatalf("got %d; want %d", n, len(rms))
|
||||
}
|
||||
nn := 0
|
||||
for i := 0; i < n; i++ {
|
||||
nn += rms[i].N
|
||||
}
|
||||
if !bytes.Equal(b[:nn], data) {
|
||||
t.Fatalf("got %#v; want %#v", b[:nn], data)
|
||||
{Buffers: [][]byte{{}}, Addr: c.LocalAddr()},
|
||||
}
|
||||
cc.SendMsgs(wms, 0)
|
||||
}
|
||||
|
||||
func BenchmarkUDP(b *testing.B) {
|
||||
|
@ -230,7 +233,7 @@ func BenchmarkUDP(b *testing.B) {
|
|||
}
|
||||
})
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
case "android", "linux":
|
||||
wms := make([]socket.Message, M)
|
||||
for i := range wms {
|
||||
wms[i].Buffers = [][]byte{data}
|
||||
|
|
|
@ -34,7 +34,7 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte {
|
|||
if ip4 := ip.To4(); ip4 != nil {
|
||||
b := make([]byte, sizeofSockaddrInet)
|
||||
switch runtime.GOOS {
|
||||
case "linux", "solaris", "windows":
|
||||
case "android", "linux", "solaris", "windows":
|
||||
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET))
|
||||
default:
|
||||
b[0] = sizeofSockaddrInet
|
||||
|
@ -47,7 +47,7 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte {
|
|||
if ip6 := ip.To16(); ip6 != nil && ip.To4() == nil {
|
||||
b := make([]byte, sizeofSockaddrInet6)
|
||||
switch runtime.GOOS {
|
||||
case "linux", "solaris", "windows":
|
||||
case "android", "linux", "solaris", "windows":
|
||||
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET6))
|
||||
default:
|
||||
b[0] = sizeofSockaddrInet6
|
||||
|
@ -69,7 +69,7 @@ func parseInetAddr(b []byte, network string) (net.Addr, error) {
|
|||
}
|
||||
var af int
|
||||
switch runtime.GOOS {
|
||||
case "linux", "solaris", "windows":
|
||||
case "android", "linux", "solaris", "windows":
|
||||
af = int(NativeEndian.Uint16(b[:2]))
|
||||
default:
|
||||
af = int(b[1])
|
||||
|
|
|
@ -981,6 +981,49 @@ const (
|
|||
MAP_STACK = 0x400
|
||||
MCL_CURRENT = 0x1
|
||||
MCL_FUTURE = 0x2
|
||||
MNT_ACLS = 0x8000000
|
||||
MNT_ASYNC = 0x40
|
||||
MNT_AUTOMOUNTED = 0x200000000
|
||||
MNT_BYFSID = 0x8000000
|
||||
MNT_CMDFLAGS = 0xd0f0000
|
||||
MNT_DEFEXPORTED = 0x200
|
||||
MNT_DELEXPORT = 0x20000
|
||||
MNT_EXKERB = 0x800
|
||||
MNT_EXPORTANON = 0x400
|
||||
MNT_EXPORTED = 0x100
|
||||
MNT_EXPUBLIC = 0x20000000
|
||||
MNT_EXRDONLY = 0x80
|
||||
MNT_FORCE = 0x80000
|
||||
MNT_GJOURNAL = 0x2000000
|
||||
MNT_IGNORE = 0x800000
|
||||
MNT_LAZY = 0x3
|
||||
MNT_LOCAL = 0x1000
|
||||
MNT_MULTILABEL = 0x4000000
|
||||
MNT_NFS4ACLS = 0x10
|
||||
MNT_NOATIME = 0x10000000
|
||||
MNT_NOCLUSTERR = 0x40000000
|
||||
MNT_NOCLUSTERW = 0x80000000
|
||||
MNT_NOEXEC = 0x4
|
||||
MNT_NONBUSY = 0x4000000
|
||||
MNT_NOSUID = 0x8
|
||||
MNT_NOSYMFOLLOW = 0x400000
|
||||
MNT_NOWAIT = 0x2
|
||||
MNT_QUOTA = 0x2000
|
||||
MNT_RDONLY = 0x1
|
||||
MNT_RELOAD = 0x40000
|
||||
MNT_ROOTFS = 0x4000
|
||||
MNT_SNAPSHOT = 0x1000000
|
||||
MNT_SOFTDEP = 0x200000
|
||||
MNT_SUIDDIR = 0x100000
|
||||
MNT_SUJ = 0x100000000
|
||||
MNT_SUSPEND = 0x4
|
||||
MNT_SYNCHRONOUS = 0x2
|
||||
MNT_UNION = 0x20
|
||||
MNT_UPDATE = 0x10000
|
||||
MNT_UPDATEMASK = 0x2d8d0807e
|
||||
MNT_USER = 0x8000
|
||||
MNT_VISFLAGMASK = 0x3fef0ffff
|
||||
MNT_WAIT = 0x1
|
||||
MSG_CMSG_CLOEXEC = 0x40000
|
||||
MSG_COMPAT = 0x8000
|
||||
MSG_CTRUNC = 0x20
|
||||
|
|
|
@ -982,6 +982,49 @@ const (
|
|||
MAP_STACK = 0x400
|
||||
MCL_CURRENT = 0x1
|
||||
MCL_FUTURE = 0x2
|
||||
MNT_ACLS = 0x8000000
|
||||
MNT_ASYNC = 0x40
|
||||
MNT_AUTOMOUNTED = 0x200000000
|
||||
MNT_BYFSID = 0x8000000
|
||||
MNT_CMDFLAGS = 0xd0f0000
|
||||
MNT_DEFEXPORTED = 0x200
|
||||
MNT_DELEXPORT = 0x20000
|
||||
MNT_EXKERB = 0x800
|
||||
MNT_EXPORTANON = 0x400
|
||||
MNT_EXPORTED = 0x100
|
||||
MNT_EXPUBLIC = 0x20000000
|
||||
MNT_EXRDONLY = 0x80
|
||||
MNT_FORCE = 0x80000
|
||||
MNT_GJOURNAL = 0x2000000
|
||||
MNT_IGNORE = 0x800000
|
||||
MNT_LAZY = 0x3
|
||||
MNT_LOCAL = 0x1000
|
||||
MNT_MULTILABEL = 0x4000000
|
||||
MNT_NFS4ACLS = 0x10
|
||||
MNT_NOATIME = 0x10000000
|
||||
MNT_NOCLUSTERR = 0x40000000
|
||||
MNT_NOCLUSTERW = 0x80000000
|
||||
MNT_NOEXEC = 0x4
|
||||
MNT_NONBUSY = 0x4000000
|
||||
MNT_NOSUID = 0x8
|
||||
MNT_NOSYMFOLLOW = 0x400000
|
||||
MNT_NOWAIT = 0x2
|
||||
MNT_QUOTA = 0x2000
|
||||
MNT_RDONLY = 0x1
|
||||
MNT_RELOAD = 0x40000
|
||||
MNT_ROOTFS = 0x4000
|
||||
MNT_SNAPSHOT = 0x1000000
|
||||
MNT_SOFTDEP = 0x200000
|
||||
MNT_SUIDDIR = 0x100000
|
||||
MNT_SUJ = 0x100000000
|
||||
MNT_SUSPEND = 0x4
|
||||
MNT_SYNCHRONOUS = 0x2
|
||||
MNT_UNION = 0x20
|
||||
MNT_UPDATE = 0x10000
|
||||
MNT_UPDATEMASK = 0x2d8d0807e
|
||||
MNT_USER = 0x8000
|
||||
MNT_VISFLAGMASK = 0x3fef0ffff
|
||||
MNT_WAIT = 0x1
|
||||
MSG_CMSG_CLOEXEC = 0x40000
|
||||
MSG_COMPAT = 0x8000
|
||||
MSG_CTRUNC = 0x20
|
||||
|
|
|
@ -989,6 +989,49 @@ const (
|
|||
MAP_STACK = 0x400
|
||||
MCL_CURRENT = 0x1
|
||||
MCL_FUTURE = 0x2
|
||||
MNT_ACLS = 0x8000000
|
||||
MNT_ASYNC = 0x40
|
||||
MNT_AUTOMOUNTED = 0x200000000
|
||||
MNT_BYFSID = 0x8000000
|
||||
MNT_CMDFLAGS = 0xd0f0000
|
||||
MNT_DEFEXPORTED = 0x200
|
||||
MNT_DELEXPORT = 0x20000
|
||||
MNT_EXKERB = 0x800
|
||||
MNT_EXPORTANON = 0x400
|
||||
MNT_EXPORTED = 0x100
|
||||
MNT_EXPUBLIC = 0x20000000
|
||||
MNT_EXRDONLY = 0x80
|
||||
MNT_FORCE = 0x80000
|
||||
MNT_GJOURNAL = 0x2000000
|
||||
MNT_IGNORE = 0x800000
|
||||
MNT_LAZY = 0x3
|
||||
MNT_LOCAL = 0x1000
|
||||
MNT_MULTILABEL = 0x4000000
|
||||
MNT_NFS4ACLS = 0x10
|
||||
MNT_NOATIME = 0x10000000
|
||||
MNT_NOCLUSTERR = 0x40000000
|
||||
MNT_NOCLUSTERW = 0x80000000
|
||||
MNT_NOEXEC = 0x4
|
||||
MNT_NONBUSY = 0x4000000
|
||||
MNT_NOSUID = 0x8
|
||||
MNT_NOSYMFOLLOW = 0x400000
|
||||
MNT_NOWAIT = 0x2
|
||||
MNT_QUOTA = 0x2000
|
||||
MNT_RDONLY = 0x1
|
||||
MNT_RELOAD = 0x40000
|
||||
MNT_ROOTFS = 0x4000
|
||||
MNT_SNAPSHOT = 0x1000000
|
||||
MNT_SOFTDEP = 0x200000
|
||||
MNT_SUIDDIR = 0x100000
|
||||
MNT_SUJ = 0x100000000
|
||||
MNT_SUSPEND = 0x4
|
||||
MNT_SYNCHRONOUS = 0x2
|
||||
MNT_UNION = 0x20
|
||||
MNT_UPDATE = 0x10000
|
||||
MNT_UPDATEMASK = 0x2d8d0807e
|
||||
MNT_USER = 0x8000
|
||||
MNT_VISFLAGMASK = 0x3fef0ffff
|
||||
MNT_WAIT = 0x1
|
||||
MSG_CMSG_CLOEXEC = 0x40000
|
||||
MSG_COMPAT = 0x8000
|
||||
MSG_CTRUNC = 0x20
|
||||
|
|
|
@ -0,0 +1,270 @@
|
|||
// mksysctl_openbsd.pl
|
||||
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||
|
||||
package unix
|
||||
|
||||
type mibentry struct {
|
||||
ctlname string
|
||||
ctloid []_C_int
|
||||
}
|
||||
|
||||
var sysctlMib = []mibentry{
|
||||
{"ddb.console", []_C_int{9, 6}},
|
||||
{"ddb.log", []_C_int{9, 7}},
|
||||
{"ddb.max_line", []_C_int{9, 3}},
|
||||
{"ddb.max_width", []_C_int{9, 2}},
|
||||
{"ddb.panic", []_C_int{9, 5}},
|
||||
{"ddb.radix", []_C_int{9, 1}},
|
||||
{"ddb.tab_stop_width", []_C_int{9, 4}},
|
||||
{"ddb.trigger", []_C_int{9, 8}},
|
||||
{"fs.posix.setuid", []_C_int{3, 1, 1}},
|
||||
{"hw.allowpowerdown", []_C_int{6, 22}},
|
||||
{"hw.byteorder", []_C_int{6, 4}},
|
||||
{"hw.cpuspeed", []_C_int{6, 12}},
|
||||
{"hw.diskcount", []_C_int{6, 10}},
|
||||
{"hw.disknames", []_C_int{6, 8}},
|
||||
{"hw.diskstats", []_C_int{6, 9}},
|
||||
{"hw.machine", []_C_int{6, 1}},
|
||||
{"hw.model", []_C_int{6, 2}},
|
||||
{"hw.ncpu", []_C_int{6, 3}},
|
||||
{"hw.ncpufound", []_C_int{6, 21}},
|
||||
{"hw.pagesize", []_C_int{6, 7}},
|
||||
{"hw.physmem", []_C_int{6, 19}},
|
||||
{"hw.product", []_C_int{6, 15}},
|
||||
{"hw.serialno", []_C_int{6, 17}},
|
||||
{"hw.setperf", []_C_int{6, 13}},
|
||||
{"hw.usermem", []_C_int{6, 20}},
|
||||
{"hw.uuid", []_C_int{6, 18}},
|
||||
{"hw.vendor", []_C_int{6, 14}},
|
||||
{"hw.version", []_C_int{6, 16}},
|
||||
{"kern.arandom", []_C_int{1, 37}},
|
||||
{"kern.argmax", []_C_int{1, 8}},
|
||||
{"kern.boottime", []_C_int{1, 21}},
|
||||
{"kern.bufcachepercent", []_C_int{1, 72}},
|
||||
{"kern.ccpu", []_C_int{1, 45}},
|
||||
{"kern.clockrate", []_C_int{1, 12}},
|
||||
{"kern.consdev", []_C_int{1, 75}},
|
||||
{"kern.cp_time", []_C_int{1, 40}},
|
||||
{"kern.cp_time2", []_C_int{1, 71}},
|
||||
{"kern.cryptodevallowsoft", []_C_int{1, 53}},
|
||||
{"kern.domainname", []_C_int{1, 22}},
|
||||
{"kern.file", []_C_int{1, 73}},
|
||||
{"kern.forkstat", []_C_int{1, 42}},
|
||||
{"kern.fscale", []_C_int{1, 46}},
|
||||
{"kern.fsync", []_C_int{1, 33}},
|
||||
{"kern.hostid", []_C_int{1, 11}},
|
||||
{"kern.hostname", []_C_int{1, 10}},
|
||||
{"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}},
|
||||
{"kern.job_control", []_C_int{1, 19}},
|
||||
{"kern.malloc.buckets", []_C_int{1, 39, 1}},
|
||||
{"kern.malloc.kmemnames", []_C_int{1, 39, 3}},
|
||||
{"kern.maxclusters", []_C_int{1, 67}},
|
||||
{"kern.maxfiles", []_C_int{1, 7}},
|
||||
{"kern.maxlocksperuid", []_C_int{1, 70}},
|
||||
{"kern.maxpartitions", []_C_int{1, 23}},
|
||||
{"kern.maxproc", []_C_int{1, 6}},
|
||||
{"kern.maxthread", []_C_int{1, 25}},
|
||||
{"kern.maxvnodes", []_C_int{1, 5}},
|
||||
{"kern.mbstat", []_C_int{1, 59}},
|
||||
{"kern.msgbuf", []_C_int{1, 48}},
|
||||
{"kern.msgbufsize", []_C_int{1, 38}},
|
||||
{"kern.nchstats", []_C_int{1, 41}},
|
||||
{"kern.netlivelocks", []_C_int{1, 76}},
|
||||
{"kern.nfiles", []_C_int{1, 56}},
|
||||
{"kern.ngroups", []_C_int{1, 18}},
|
||||
{"kern.nosuidcoredump", []_C_int{1, 32}},
|
||||
{"kern.nprocs", []_C_int{1, 47}},
|
||||
{"kern.nselcoll", []_C_int{1, 43}},
|
||||
{"kern.nthreads", []_C_int{1, 26}},
|
||||
{"kern.numvnodes", []_C_int{1, 58}},
|
||||
{"kern.osrelease", []_C_int{1, 2}},
|
||||
{"kern.osrevision", []_C_int{1, 3}},
|
||||
{"kern.ostype", []_C_int{1, 1}},
|
||||
{"kern.osversion", []_C_int{1, 27}},
|
||||
{"kern.pool_debug", []_C_int{1, 77}},
|
||||
{"kern.posix1version", []_C_int{1, 17}},
|
||||
{"kern.proc", []_C_int{1, 66}},
|
||||
{"kern.random", []_C_int{1, 31}},
|
||||
{"kern.rawpartition", []_C_int{1, 24}},
|
||||
{"kern.saved_ids", []_C_int{1, 20}},
|
||||
{"kern.securelevel", []_C_int{1, 9}},
|
||||
{"kern.seminfo", []_C_int{1, 61}},
|
||||
{"kern.shminfo", []_C_int{1, 62}},
|
||||
{"kern.somaxconn", []_C_int{1, 28}},
|
||||
{"kern.sominconn", []_C_int{1, 29}},
|
||||
{"kern.splassert", []_C_int{1, 54}},
|
||||
{"kern.stackgap_random", []_C_int{1, 50}},
|
||||
{"kern.sysvipc_info", []_C_int{1, 51}},
|
||||
{"kern.sysvmsg", []_C_int{1, 34}},
|
||||
{"kern.sysvsem", []_C_int{1, 35}},
|
||||
{"kern.sysvshm", []_C_int{1, 36}},
|
||||
{"kern.timecounter.choice", []_C_int{1, 69, 4}},
|
||||
{"kern.timecounter.hardware", []_C_int{1, 69, 3}},
|
||||
{"kern.timecounter.tick", []_C_int{1, 69, 1}},
|
||||
{"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}},
|
||||
{"kern.tty.maxptys", []_C_int{1, 44, 6}},
|
||||
{"kern.tty.nptys", []_C_int{1, 44, 7}},
|
||||
{"kern.tty.tk_cancc", []_C_int{1, 44, 4}},
|
||||
{"kern.tty.tk_nin", []_C_int{1, 44, 1}},
|
||||
{"kern.tty.tk_nout", []_C_int{1, 44, 2}},
|
||||
{"kern.tty.tk_rawcc", []_C_int{1, 44, 3}},
|
||||
{"kern.tty.ttyinfo", []_C_int{1, 44, 5}},
|
||||
{"kern.ttycount", []_C_int{1, 57}},
|
||||
{"kern.userasymcrypto", []_C_int{1, 60}},
|
||||
{"kern.usercrypto", []_C_int{1, 52}},
|
||||
{"kern.usermount", []_C_int{1, 30}},
|
||||
{"kern.version", []_C_int{1, 4}},
|
||||
{"kern.vnode", []_C_int{1, 13}},
|
||||
{"kern.watchdog.auto", []_C_int{1, 64, 2}},
|
||||
{"kern.watchdog.period", []_C_int{1, 64, 1}},
|
||||
{"net.bpf.bufsize", []_C_int{4, 31, 1}},
|
||||
{"net.bpf.maxbufsize", []_C_int{4, 31, 2}},
|
||||
{"net.inet.ah.enable", []_C_int{4, 2, 51, 1}},
|
||||
{"net.inet.ah.stats", []_C_int{4, 2, 51, 2}},
|
||||
{"net.inet.carp.allow", []_C_int{4, 2, 112, 1}},
|
||||
{"net.inet.carp.log", []_C_int{4, 2, 112, 3}},
|
||||
{"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}},
|
||||
{"net.inet.carp.stats", []_C_int{4, 2, 112, 4}},
|
||||
{"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}},
|
||||
{"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}},
|
||||
{"net.inet.divert.stats", []_C_int{4, 2, 258, 3}},
|
||||
{"net.inet.esp.enable", []_C_int{4, 2, 50, 1}},
|
||||
{"net.inet.esp.stats", []_C_int{4, 2, 50, 4}},
|
||||
{"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}},
|
||||
{"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}},
|
||||
{"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}},
|
||||
{"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}},
|
||||
{"net.inet.gre.allow", []_C_int{4, 2, 47, 1}},
|
||||
{"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}},
|
||||
{"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}},
|
||||
{"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}},
|
||||
{"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}},
|
||||
{"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}},
|
||||
{"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}},
|
||||
{"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}},
|
||||
{"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}},
|
||||
{"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}},
|
||||
{"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}},
|
||||
{"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}},
|
||||
{"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}},
|
||||
{"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}},
|
||||
{"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}},
|
||||
{"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}},
|
||||
{"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}},
|
||||
{"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}},
|
||||
{"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}},
|
||||
{"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}},
|
||||
{"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}},
|
||||
{"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}},
|
||||
{"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}},
|
||||
{"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}},
|
||||
{"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}},
|
||||
{"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}},
|
||||
{"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}},
|
||||
{"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}},
|
||||
{"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}},
|
||||
{"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}},
|
||||
{"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}},
|
||||
{"net.inet.ip.stats", []_C_int{4, 2, 0, 33}},
|
||||
{"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}},
|
||||
{"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}},
|
||||
{"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}},
|
||||
{"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}},
|
||||
{"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}},
|
||||
{"net.inet.mobileip.allow", []_C_int{4, 2, 55, 1}},
|
||||
{"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}},
|
||||
{"net.inet.pim.stats", []_C_int{4, 2, 103, 1}},
|
||||
{"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}},
|
||||
{"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}},
|
||||
{"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}},
|
||||
{"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}},
|
||||
{"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}},
|
||||
{"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}},
|
||||
{"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}},
|
||||
{"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}},
|
||||
{"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}},
|
||||
{"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}},
|
||||
{"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}},
|
||||
{"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}},
|
||||
{"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}},
|
||||
{"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}},
|
||||
{"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}},
|
||||
{"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}},
|
||||
{"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}},
|
||||
{"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}},
|
||||
{"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}},
|
||||
{"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}},
|
||||
{"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}},
|
||||
{"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}},
|
||||
{"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}},
|
||||
{"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}},
|
||||
{"net.inet.udp.stats", []_C_int{4, 2, 17, 5}},
|
||||
{"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}},
|
||||
{"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}},
|
||||
{"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}},
|
||||
{"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}},
|
||||
{"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}},
|
||||
{"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}},
|
||||
{"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}},
|
||||
{"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}},
|
||||
{"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}},
|
||||
{"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}},
|
||||
{"net.inet6.icmp6.nd6_prune", []_C_int{4, 24, 30, 6}},
|
||||
{"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}},
|
||||
{"net.inet6.icmp6.nd6_useloopback", []_C_int{4, 24, 30, 11}},
|
||||
{"net.inet6.icmp6.nodeinfo", []_C_int{4, 24, 30, 13}},
|
||||
{"net.inet6.icmp6.rediraccept", []_C_int{4, 24, 30, 2}},
|
||||
{"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}},
|
||||
{"net.inet6.ip6.accept_rtadv", []_C_int{4, 24, 17, 12}},
|
||||
{"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}},
|
||||
{"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}},
|
||||
{"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}},
|
||||
{"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}},
|
||||
{"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}},
|
||||
{"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}},
|
||||
{"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}},
|
||||
{"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}},
|
||||
{"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}},
|
||||
{"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}},
|
||||
{"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}},
|
||||
{"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}},
|
||||
{"net.inet6.ip6.maxifdefrouters", []_C_int{4, 24, 17, 47}},
|
||||
{"net.inet6.ip6.maxifprefixes", []_C_int{4, 24, 17, 46}},
|
||||
{"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}},
|
||||
{"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}},
|
||||
{"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}},
|
||||
{"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}},
|
||||
{"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}},
|
||||
{"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}},
|
||||
{"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}},
|
||||
{"net.inet6.ip6.rr_prune", []_C_int{4, 24, 17, 22}},
|
||||
{"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}},
|
||||
{"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}},
|
||||
{"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}},
|
||||
{"net.inet6.ip6.v6only", []_C_int{4, 24, 17, 24}},
|
||||
{"net.key.sadb_dump", []_C_int{4, 30, 1}},
|
||||
{"net.key.spd_dump", []_C_int{4, 30, 2}},
|
||||
{"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}},
|
||||
{"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}},
|
||||
{"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}},
|
||||
{"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}},
|
||||
{"net.mpls.mapttl_ip", []_C_int{4, 33, 5}},
|
||||
{"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}},
|
||||
{"net.mpls.maxloop_inkernel", []_C_int{4, 33, 4}},
|
||||
{"net.mpls.ttl", []_C_int{4, 33, 2}},
|
||||
{"net.pflow.stats", []_C_int{4, 34, 1}},
|
||||
{"net.pipex.enable", []_C_int{4, 35, 1}},
|
||||
{"vm.anonmin", []_C_int{2, 7}},
|
||||
{"vm.loadavg", []_C_int{2, 2}},
|
||||
{"vm.maxslp", []_C_int{2, 10}},
|
||||
{"vm.nkmempages", []_C_int{2, 6}},
|
||||
{"vm.psstrings", []_C_int{2, 3}},
|
||||
{"vm.swapencrypt.enable", []_C_int{2, 5, 0}},
|
||||
{"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}},
|
||||
{"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}},
|
||||
{"vm.uspace", []_C_int{2, 11}},
|
||||
{"vm.uvmexp", []_C_int{2, 4}},
|
||||
{"vm.vmmeter", []_C_int{2, 1}},
|
||||
{"vm.vnodemin", []_C_int{2, 9}},
|
||||
{"vm.vtextmin", []_C_int{2, 8}},
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
// mksysctl_openbsd.pl
|
||||
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
||||
|
||||
package unix
|
||||
|
||||
type mibentry struct {
|
||||
ctlname string
|
||||
ctloid []_C_int
|
||||
}
|
||||
|
||||
var sysctlMib = []mibentry{
|
||||
{"ddb.console", []_C_int{9, 6}},
|
||||
{"ddb.log", []_C_int{9, 7}},
|
||||
{"ddb.max_line", []_C_int{9, 3}},
|
||||
{"ddb.max_width", []_C_int{9, 2}},
|
||||
{"ddb.panic", []_C_int{9, 5}},
|
||||
{"ddb.radix", []_C_int{9, 1}},
|
||||
{"ddb.tab_stop_width", []_C_int{9, 4}},
|
||||
{"ddb.trigger", []_C_int{9, 8}},
|
||||
{"fs.posix.setuid", []_C_int{3, 1, 1}},
|
||||
{"hw.allowpowerdown", []_C_int{6, 22}},
|
||||
{"hw.byteorder", []_C_int{6, 4}},
|
||||
{"hw.cpuspeed", []_C_int{6, 12}},
|
||||
{"hw.diskcount", []_C_int{6, 10}},
|
||||
{"hw.disknames", []_C_int{6, 8}},
|
||||
{"hw.diskstats", []_C_int{6, 9}},
|
||||
{"hw.machine", []_C_int{6, 1}},
|
||||
{"hw.model", []_C_int{6, 2}},
|
||||
{"hw.ncpu", []_C_int{6, 3}},
|
||||
{"hw.ncpufound", []_C_int{6, 21}},
|
||||
{"hw.pagesize", []_C_int{6, 7}},
|
||||
{"hw.physmem", []_C_int{6, 19}},
|
||||
{"hw.product", []_C_int{6, 15}},
|
||||
{"hw.serialno", []_C_int{6, 17}},
|
||||
{"hw.setperf", []_C_int{6, 13}},
|
||||
{"hw.usermem", []_C_int{6, 20}},
|
||||
{"hw.uuid", []_C_int{6, 18}},
|
||||
{"hw.vendor", []_C_int{6, 14}},
|
||||
{"hw.version", []_C_int{6, 16}},
|
||||
{"kern.arandom", []_C_int{1, 37}},
|
||||
{"kern.argmax", []_C_int{1, 8}},
|
||||
{"kern.boottime", []_C_int{1, 21}},
|
||||
{"kern.bufcachepercent", []_C_int{1, 72}},
|
||||
{"kern.ccpu", []_C_int{1, 45}},
|
||||
{"kern.clockrate", []_C_int{1, 12}},
|
||||
{"kern.consdev", []_C_int{1, 75}},
|
||||
{"kern.cp_time", []_C_int{1, 40}},
|
||||
{"kern.cp_time2", []_C_int{1, 71}},
|
||||
{"kern.cryptodevallowsoft", []_C_int{1, 53}},
|
||||
{"kern.domainname", []_C_int{1, 22}},
|
||||
{"kern.file", []_C_int{1, 73}},
|
||||
{"kern.forkstat", []_C_int{1, 42}},
|
||||
{"kern.fscale", []_C_int{1, 46}},
|
||||
{"kern.fsync", []_C_int{1, 33}},
|
||||
{"kern.hostid", []_C_int{1, 11}},
|
||||
{"kern.hostname", []_C_int{1, 10}},
|
||||
{"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}},
|
||||
{"kern.job_control", []_C_int{1, 19}},
|
||||
{"kern.malloc.buckets", []_C_int{1, 39, 1}},
|
||||
{"kern.malloc.kmemnames", []_C_int{1, 39, 3}},
|
||||
{"kern.maxclusters", []_C_int{1, 67}},
|
||||
{"kern.maxfiles", []_C_int{1, 7}},
|
||||
{"kern.maxlocksperuid", []_C_int{1, 70}},
|
||||
{"kern.maxpartitions", []_C_int{1, 23}},
|
||||
{"kern.maxproc", []_C_int{1, 6}},
|
||||
{"kern.maxthread", []_C_int{1, 25}},
|
||||
{"kern.maxvnodes", []_C_int{1, 5}},
|
||||
{"kern.mbstat", []_C_int{1, 59}},
|
||||
{"kern.msgbuf", []_C_int{1, 48}},
|
||||
{"kern.msgbufsize", []_C_int{1, 38}},
|
||||
{"kern.nchstats", []_C_int{1, 41}},
|
||||
{"kern.netlivelocks", []_C_int{1, 76}},
|
||||
{"kern.nfiles", []_C_int{1, 56}},
|
||||
{"kern.ngroups", []_C_int{1, 18}},
|
||||
{"kern.nosuidcoredump", []_C_int{1, 32}},
|
||||
{"kern.nprocs", []_C_int{1, 47}},
|
||||
{"kern.nselcoll", []_C_int{1, 43}},
|
||||
{"kern.nthreads", []_C_int{1, 26}},
|
||||
{"kern.numvnodes", []_C_int{1, 58}},
|
||||
{"kern.osrelease", []_C_int{1, 2}},
|
||||
{"kern.osrevision", []_C_int{1, 3}},
|
||||
{"kern.ostype", []_C_int{1, 1}},
|
||||
{"kern.osversion", []_C_int{1, 27}},
|
||||
{"kern.pool_debug", []_C_int{1, 77}},
|
||||
{"kern.posix1version", []_C_int{1, 17}},
|
||||
{"kern.proc", []_C_int{1, 66}},
|
||||
{"kern.random", []_C_int{1, 31}},
|
||||
{"kern.rawpartition", []_C_int{1, 24}},
|
||||
{"kern.saved_ids", []_C_int{1, 20}},
|
||||
{"kern.securelevel", []_C_int{1, 9}},
|
||||
{"kern.seminfo", []_C_int{1, 61}},
|
||||
{"kern.shminfo", []_C_int{1, 62}},
|
||||
{"kern.somaxconn", []_C_int{1, 28}},
|
||||
{"kern.sominconn", []_C_int{1, 29}},
|
||||
{"kern.splassert", []_C_int{1, 54}},
|
||||
{"kern.stackgap_random", []_C_int{1, 50}},
|
||||
{"kern.sysvipc_info", []_C_int{1, 51}},
|
||||
{"kern.sysvmsg", []_C_int{1, 34}},
|
||||
{"kern.sysvsem", []_C_int{1, 35}},
|
||||
{"kern.sysvshm", []_C_int{1, 36}},
|
||||
{"kern.timecounter.choice", []_C_int{1, 69, 4}},
|
||||
{"kern.timecounter.hardware", []_C_int{1, 69, 3}},
|
||||
{"kern.timecounter.tick", []_C_int{1, 69, 1}},
|
||||
{"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}},
|
||||
{"kern.tty.maxptys", []_C_int{1, 44, 6}},
|
||||
{"kern.tty.nptys", []_C_int{1, 44, 7}},
|
||||
{"kern.tty.tk_cancc", []_C_int{1, 44, 4}},
|
||||
{"kern.tty.tk_nin", []_C_int{1, 44, 1}},
|
||||
{"kern.tty.tk_nout", []_C_int{1, 44, 2}},
|
||||
{"kern.tty.tk_rawcc", []_C_int{1, 44, 3}},
|
||||
{"kern.tty.ttyinfo", []_C_int{1, 44, 5}},
|
||||
{"kern.ttycount", []_C_int{1, 57}},
|
||||
{"kern.userasymcrypto", []_C_int{1, 60}},
|
||||
{"kern.usercrypto", []_C_int{1, 52}},
|
||||
{"kern.usermount", []_C_int{1, 30}},
|
||||
{"kern.version", []_C_int{1, 4}},
|
||||
{"kern.vnode", []_C_int{1, 13}},
|
||||
{"kern.watchdog.auto", []_C_int{1, 64, 2}},
|
||||
{"kern.watchdog.period", []_C_int{1, 64, 1}},
|
||||
{"net.bpf.bufsize", []_C_int{4, 31, 1}},
|
||||
{"net.bpf.maxbufsize", []_C_int{4, 31, 2}},
|
||||
{"net.inet.ah.enable", []_C_int{4, 2, 51, 1}},
|
||||
{"net.inet.ah.stats", []_C_int{4, 2, 51, 2}},
|
||||
{"net.inet.carp.allow", []_C_int{4, 2, 112, 1}},
|
||||
{"net.inet.carp.log", []_C_int{4, 2, 112, 3}},
|
||||
{"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}},
|
||||
{"net.inet.carp.stats", []_C_int{4, 2, 112, 4}},
|
||||
{"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}},
|
||||
{"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}},
|
||||
{"net.inet.divert.stats", []_C_int{4, 2, 258, 3}},
|
||||
{"net.inet.esp.enable", []_C_int{4, 2, 50, 1}},
|
||||
{"net.inet.esp.stats", []_C_int{4, 2, 50, 4}},
|
||||
{"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}},
|
||||
{"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}},
|
||||
{"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}},
|
||||
{"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}},
|
||||
{"net.inet.gre.allow", []_C_int{4, 2, 47, 1}},
|
||||
{"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}},
|
||||
{"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}},
|
||||
{"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}},
|
||||
{"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}},
|
||||
{"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}},
|
||||
{"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}},
|
||||
{"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}},
|
||||
{"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}},
|
||||
{"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}},
|
||||
{"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}},
|
||||
{"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}},
|
||||
{"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}},
|
||||
{"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}},
|
||||
{"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}},
|
||||
{"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}},
|
||||
{"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}},
|
||||
{"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}},
|
||||
{"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}},
|
||||
{"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}},
|
||||
{"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}},
|
||||
{"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}},
|
||||
{"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}},
|
||||
{"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}},
|
||||
{"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}},
|
||||
{"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}},
|
||||
{"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}},
|
||||
{"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}},
|
||||
{"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}},
|
||||
{"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}},
|
||||
{"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}},
|
||||
{"net.inet.ip.stats", []_C_int{4, 2, 0, 33}},
|
||||
{"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}},
|
||||
{"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}},
|
||||
{"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}},
|
||||
{"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}},
|
||||
{"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}},
|
||||
{"net.inet.mobileip.allow", []_C_int{4, 2, 55, 1}},
|
||||
{"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}},
|
||||
{"net.inet.pim.stats", []_C_int{4, 2, 103, 1}},
|
||||
{"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}},
|
||||
{"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}},
|
||||
{"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}},
|
||||
{"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}},
|
||||
{"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}},
|
||||
{"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}},
|
||||
{"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}},
|
||||
{"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}},
|
||||
{"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}},
|
||||
{"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}},
|
||||
{"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}},
|
||||
{"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}},
|
||||
{"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}},
|
||||
{"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}},
|
||||
{"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}},
|
||||
{"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}},
|
||||
{"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}},
|
||||
{"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}},
|
||||
{"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}},
|
||||
{"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}},
|
||||
{"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}},
|
||||
{"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}},
|
||||
{"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}},
|
||||
{"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}},
|
||||
{"net.inet.udp.stats", []_C_int{4, 2, 17, 5}},
|
||||
{"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}},
|
||||
{"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}},
|
||||
{"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}},
|
||||
{"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}},
|
||||
{"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}},
|
||||
{"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}},
|
||||
{"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}},
|
||||
{"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}},
|
||||
{"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}},
|
||||
{"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}},
|
||||
{"net.inet6.icmp6.nd6_prune", []_C_int{4, 24, 30, 6}},
|
||||
{"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}},
|
||||
{"net.inet6.icmp6.nd6_useloopback", []_C_int{4, 24, 30, 11}},
|
||||
{"net.inet6.icmp6.nodeinfo", []_C_int{4, 24, 30, 13}},
|
||||
{"net.inet6.icmp6.rediraccept", []_C_int{4, 24, 30, 2}},
|
||||
{"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}},
|
||||
{"net.inet6.ip6.accept_rtadv", []_C_int{4, 24, 17, 12}},
|
||||
{"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}},
|
||||
{"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}},
|
||||
{"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}},
|
||||
{"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}},
|
||||
{"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}},
|
||||
{"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}},
|
||||
{"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}},
|
||||
{"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}},
|
||||
{"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}},
|
||||
{"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}},
|
||||
{"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}},
|
||||
{"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}},
|
||||
{"net.inet6.ip6.maxifdefrouters", []_C_int{4, 24, 17, 47}},
|
||||
{"net.inet6.ip6.maxifprefixes", []_C_int{4, 24, 17, 46}},
|
||||
{"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}},
|
||||
{"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}},
|
||||
{"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}},
|
||||
{"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}},
|
||||
{"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}},
|
||||
{"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}},
|
||||
{"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}},
|
||||
{"net.inet6.ip6.rr_prune", []_C_int{4, 24, 17, 22}},
|
||||
{"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}},
|
||||
{"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}},
|
||||
{"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}},
|
||||
{"net.inet6.ip6.v6only", []_C_int{4, 24, 17, 24}},
|
||||
{"net.key.sadb_dump", []_C_int{4, 30, 1}},
|
||||
{"net.key.spd_dump", []_C_int{4, 30, 2}},
|
||||
{"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}},
|
||||
{"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}},
|
||||
{"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}},
|
||||
{"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}},
|
||||
{"net.mpls.mapttl_ip", []_C_int{4, 33, 5}},
|
||||
{"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}},
|
||||
{"net.mpls.maxloop_inkernel", []_C_int{4, 33, 4}},
|
||||
{"net.mpls.ttl", []_C_int{4, 33, 2}},
|
||||
{"net.pflow.stats", []_C_int{4, 34, 1}},
|
||||
{"net.pipex.enable", []_C_int{4, 35, 1}},
|
||||
{"vm.anonmin", []_C_int{2, 7}},
|
||||
{"vm.loadavg", []_C_int{2, 2}},
|
||||
{"vm.maxslp", []_C_int{2, 10}},
|
||||
{"vm.nkmempages", []_C_int{2, 6}},
|
||||
{"vm.psstrings", []_C_int{2, 3}},
|
||||
{"vm.swapencrypt.enable", []_C_int{2, 5, 0}},
|
||||
{"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}},
|
||||
{"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}},
|
||||
{"vm.uspace", []_C_int{2, 11}},
|
||||
{"vm.uvmexp", []_C_int{2, 4}},
|
||||
{"vm.vmmeter", []_C_int{2, 1}},
|
||||
{"vm.vnodemin", []_C_int{2, 9}},
|
||||
{"vm.vtextmin", []_C_int{2, 8}},
|
||||
}
|
Loading…
Reference in New Issue