update vendor

This commit is contained in:
deepzz0
2017-07-08 12:16:15 +08:00
parent 8dc73fd67c
commit 3923bc70f1
63 changed files with 1590 additions and 216 deletions

10
glide.lock generated
View File

@@ -1,8 +1,10 @@
hash: bd360fa297ed66950543990f9433cdcdf13c29dd99d9a01b49027e236b2cb9da hash: bd360fa297ed66950543990f9433cdcdf13c29dd99d9a01b49027e236b2cb9da
updated: 2017-06-14T20:34:29.429161691+08:00 updated: 2017-07-08T12:15:52.531289524+08:00
imports: imports:
- name: github.com/boj/redistore - name: github.com/boj/redistore
version: 4562487a4bee9a7c272b72bfaeda4917d0a47ab9 version: 4562487a4bee9a7c272b72bfaeda4917d0a47ab9
- name: github.com/deepzz0/logd
version: 2bbe53d047054777f3a171cdfc6dca7aa9f8af78
- name: github.com/eiblog/blackfriday - name: github.com/eiblog/blackfriday
version: c0ec111761ae784fe31cc076f2fa0e2d2216d623 version: c0ec111761ae784fe31cc076f2fa0e2d2216d623
- name: github.com/eiblog/utils - name: github.com/eiblog/utils
@@ -13,7 +15,7 @@ imports:
- tmpl - tmpl
- uuid - uuid
- name: github.com/garyburd/redigo - name: github.com/garyburd/redigo
version: 95d11dba2d44531bdb8022752b98912baafae03a version: 57f1cd7de6175c96b423e7ac2534ff2b39e2ef79
subpackages: subpackages:
- internal - internal
- redis - redis
@@ -47,7 +49,7 @@ imports:
subpackages: subpackages:
- context - context
- name: golang.org/x/sys - name: golang.org/x/sys
version: 0b25a408a50076fbbcae6b7ac0ea5fbb0b085e79 version: 739734461d1c916b6c72a63d7efda2b27edb369f
subpackages: subpackages:
- unix - unix
- name: gopkg.in/go-playground/validator.v8 - name: gopkg.in/go-playground/validator.v8
@@ -62,7 +64,7 @@ imports:
- name: gopkg.in/yaml.v2 - name: gopkg.in/yaml.v2
version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
- name: qiniupkg.com/api.v7 - name: qiniupkg.com/api.v7
version: 89344a711feec1d800c77a80d0865de936dc394d version: 33f18792da10ba96109ee98a0c7fe53cd6a8a65a
subpackages: subpackages:
- api - api
- auth/qbox - auth/qbox

1
vendor/github.com/deepzz0/logd/.gitignore generated vendored Normal file
View File

@@ -0,0 +1 @@
.DS_Store

149
vendor/github.com/deepzz0/logd/README.md generated vendored Normal file
View File

@@ -0,0 +1,149 @@
# Logd
高性能日志系统每日24时自动打包前一天数据自动删除过期数据30天自动邮件告警。
#### Bechmark
```
BenchmarkLogFileChan-8 500000 2265 ns/op
BenchmarkLogFile-8 300000 4393 ns/op
BenchmarkStandardFile-8 1000000 2216 ns/op
BenchmarkLogFileChanMillion-8 1000000 2319 ns/op
BenchmarkLogFileMillion-8 1000000 4397 ns/op
BenchmarkStandardFileMillion-8 1000000 2232 ns/op
```
#### Print Level
```
Ldebug = 1 << iota //
Linfo //
Lwarn //
Lerror //
Lfatal //
logd.Printf()
logd.Print()
logd.Debugf()
logd.Debug()
logd.Infof()
logd.Info()
logd.Warnf()
logd.Warn()
logd.Errorf()
logd.Error()
logd.Fatalf()
logd.Fatal()
```
5种日志等级12种打印方法完全理解你记录日志的需求。
```
Ldebug < Linfo < Lwarn < Lerror < Lfatal
```
通过`SetLevel()`方法设置logd.SetLevel(Lwarn)系统只会打印大于等于Lwarn的日志。
> 注意logd.Printf() 和 logd.Print() 不论等级为什么都会输出,请悉知。
#### Print Option
系统提供多种格式输出选项:
```
Lasync // 异步输出日志
Ldate // like 2006/01/02
Ltime // like 15:04:05
Lmicroseconds // like 15:04:05.123123
Llongfile // like /a/b/c/d.go:23
Lshortfile // like d.go:23
LUTC // 时间utc输出
Ldaily // 按天归档
默认提供:
LstdFlags // 2006/01/02 15:04:05.123123, /a/b/c/d.go:23
```
#### 使用方法
1、默认方式
默认方式使用以下配置选项:
```
// 2006/01/02 15:04:05.123123, /a/b/c/d.go:23
Lall = Ldebug | Linfo | Lwarn | Lerror | Lfatal
LstdFlags = Lall | Ldate | Lmicroseconds | Lshortfile
```
这里会打印所有等级日志,打印日志格式为`2006/01/02 15:04:05.123123, /a/b/c/d.go:23`
可以通过`logd.SetLevel(level)`方式调整日志等级。`logd.SetOutput(writer)`输出日志到别的地方。例子:
```
package main
import (
"fmt"
"os"
"github.com/deepzz0/logd"
)
func main() {
logd.Printf("Printf: foo\n")
logd.Print("Print: foo")
logd.Debugf("Debugf: foo\n")
logd.Debug("Debug: foo")
logd.Errorf("Errorf: foo\n")
logd.Error("Error: foo")
// 改变输出等级
logd.SetLevel(logd.Lerror)
// 不论等级如何都会输出
fmt.Println("----- 改变日志等级为Lerror -----")
logd.Printf("Printf: foo\n")
logd.Print("Print: foo")
logd.Debugf("Debugf: foo\n")
logd.Debug("Debug: foo")
logd.Errorf("Errorf: foo\n")
logd.Error("Error: foo")
fmt.Println("----- 日志等级为Lerror并写入到test.log中 -----")
f, err := os.Create("./test.log")
if err != nil {
panic(err)
}
defer f.Close()
logd.SetOutput(f)
logd.Printf("Printf: foo\n")
logd.Print("Print: foo")
logd.Debugf("Debugf: foo\n")
logd.Debug("Debug: foo")
logd.Errorf("Errorf: foo\n")
logd.Error("Error: foo")
}
```
输出如下:
![logd_print](http://7xokm2.com1.z0.glb.clouddn.com/img/logd_print.png)
1、自定义配置
推荐需要将日志保存下来的用户使用。
```
Flags := Lwarn | Lerror | Lfatal | Ldate | Ltime | Lshortfile | Ldaily | Lasync
f, _ := os.OpenFile("testdata/onlyfile.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
log := New(LogOption{
Out: f,
Flag: Flags,
LogDir: "testdata",
ChannelLen: 1000,
})
```
* 输出日志等级Lwarn | Lerror | Lfatal
* 输出日志格式Ldate | Ltime | Lshortfile
* 按日归档Ldaily
* 异步输出Lasync
它会将每天的日志,采用 gzip 压缩,并保留 30 天以内的日志。自动删除 30 以前的日志。

489
vendor/github.com/deepzz0/logd/logd.go generated vendored Normal file
View File

@@ -0,0 +1,489 @@
package logd
import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
)
const (
Ldebug = 1 << iota //
Linfo //
Lwarn //
Lerror //
Lfatal //
Ldate // 如2006/01/02
Ltime // 如15:04:05
Lmicroseconds // 如15:04:05.123123
Llongfile // 如:/a/b/c/d.go:23
Lshortfile // 如d.go:23
LUTC // 时间utc输出
LAsync // 异步输出日志
LDaily // 按日归档保留30天
//
// 建议标准格式为: LVEVL | FORMAT | ROTATE | ASYNC
//
Lall = Ldebug | Linfo | Lwarn | Lerror | Lfatal
// 2006/01/02 15:04:05.123123, d.go:23
LstdFlags = Lall | Ldate | Lmicroseconds | Lshortfile
// 2006/01/02 15:04:05, d.go:23
LwarnFlags = Lwarn | Lerror | Lfatal | Ldate | Ltime | Lshortfile | LDaily | LAsync
)
// 等级显示字符串
var levelMaps = map[int]string{
Ldebug: "DEBUG",
Linfo: "INFO",
Lwarn: "WARN",
Lerror: "ERROR",
Lfatal: "FATAL",
}
// 日志结构体
type Logger struct {
mu sync.Mutex
obj string // 打印日志对象
out io.Writer // 输出
in chan []byte // channel
dir string // 输出目录
flag int // 标志
mails Emailer // 告警邮件
}
// 日志配置项
type LogOption struct {
Out io.Writer // 输出writer
LogDir string // 日志输出目录,为空不输出到文件
ChannelLen int // channel
Flag int // 标志位
Mails Emailer // 告警邮件
}
// 新建日志打印器
func New(option LogOption) *Logger {
wd, _ := os.Getwd()
index := strings.LastIndex(wd, "/")
logger := &Logger{
obj: wd[index+1:],
out: option.Out,
in: make(chan []byte, option.ChannelLen),
dir: option.LogDir,
flag: option.Flag,
mails: option.Mails,
}
if logger.flag|LAsync != 0 {
go logger.receive()
}
return logger
}
func (l *Logger) receive() {
today := time.Now()
var file *os.File
var err error
for data := range l.in {
if l.dir != "" && (file == nil || today.Day() != time.Now().Day()) {
l.mu.Lock()
today = time.Now()
file, err = os.OpenFile(fmt.Sprintf("%s/%s_%s.log", l.dir, l.obj, today.Format("2006-01-02")), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
if err != nil {
panic(err)
}
l.mu.Unlock()
if l.flag&LDaily != 0 {
go l.rotate(today)
}
}
if file != nil {
file.Write(data)
}
if l.out != nil {
l.out.Write(data)
}
}
}
// 压缩
func (l *Logger) rotate(t time.Time) {
filepath.Walk(l.dir, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
if int(t.Sub(f.ModTime()).Hours()) > 24 {
if strings.HasSuffix(f.Name(), ".log") {
cmd := exec.Command("gzip", path)
err = cmd.Run()
if err != nil {
return err
}
}
}
if int(t.Sub(f.ModTime()).Hours()) > 24*30 {
if err := os.Remove(path); err != nil {
return err
}
}
return nil
})
}
// 日志基本格式: date, time(hour:minute:second:microsecond), level, module, shortfile:line, <content>
func (l *Logger) Output(lvl int, calldepth int, content string) error {
_, file, line, ok := runtime.Caller(calldepth)
if !ok {
return nil
}
var buf []byte
l.formatHeader(&buf, lvl, time.Now(), file, line)
buf = append(buf, content...)
if l.mails != nil && lvl >= Lwarn {
go l.mails.SendMail(l.obj, buf)
}
// 异步输出
if l.flag&LAsync != 0 {
l.in <- buf
} else {
l.mu.Lock()
defer l.mu.Unlock()
l.out.Write(buf)
}
return nil
}
// 整理日志header
func (l *Logger) formatHeader(buf *[]byte, lvl int, t time.Time, file string, line int) {
if l.flag&LUTC != 0 {
t = t.UTC()
}
if l.flag&(Ldate|Ltime|Lmicroseconds) != 0 {
if l.flag&Ldate != 0 {
year, month, day := t.Date()
itoa(buf, year, 4)
*buf = append(*buf, '/')
itoa(buf, int(month), 2)
*buf = append(*buf, '/')
itoa(buf, day, 2)
*buf = append(*buf, ' ')
}
if l.flag&(Ltime|Lmicroseconds) != 0 {
hour, min, sec := t.Clock()
itoa(buf, hour, 2)
*buf = append(*buf, ':')
itoa(buf, min, 2)
*buf = append(*buf, ':')
itoa(buf, sec, 2)
if l.flag&Lmicroseconds != 0 {
*buf = append(*buf, '.')
itoa(buf, t.Nanosecond()/1e3, 6)
}
*buf = append(*buf, ' ')
}
}
*buf = append(*buf, getColorLevel(levelMaps[lvl])...)
*buf = append(*buf, ' ')
if l.flag&(Lshortfile|Llongfile) != 0 {
if l.flag&Lshortfile != 0 {
short := file
for i := len(file) - 1; i > 0; i-- {
if file[i] == '/' {
short = file[i+1:]
break
}
}
file = short
}
*buf = append(*buf, file...)
*buf = append(*buf, ':')
itoa(buf, line, -1)
*buf = append(*buf, ":"...)
}
}
// 等待flush channel
func (l *Logger) WaitFlush() {
for {
if len(l.in) > 0 {
time.Sleep(time.Nanosecond * 50)
} else {
break
}
}
}
// print
func (l *Logger) Printf(format string, v ...interface{}) {
l.Output(Linfo, 2, fmt.Sprintf(format, v...))
}
func (l *Logger) Print(v ...interface{}) {
l.Output(Linfo, 2, fmt.Sprintf(smartFormat(v...), v...))
}
// debug
func (l *Logger) Debugf(format string, v ...interface{}) {
if Ldebug&l.flag != 0 {
l.Output(Ldebug, 2, fmt.Sprintf(format, v...))
}
}
func (l *Logger) Debug(v ...interface{}) {
if Ldebug&l.flag != 0 {
l.Output(Ldebug, 2, fmt.Sprintf(smartFormat(v...), v...))
}
}
// info
func (l *Logger) Infof(format string, v ...interface{}) {
if Linfo&l.flag != 0 {
l.Output(Linfo, 2, fmt.Sprintf(format, v...))
}
}
func (l *Logger) Info(v ...interface{}) {
if Linfo&l.flag != 0 {
l.Output(Linfo, 2, fmt.Sprintf(smartFormat(v...), v...))
}
}
// warn
func (l *Logger) Warnf(format string, v ...interface{}) {
if Lwarn&l.flag != 0 {
l.Output(Lwarn, 2, fmt.Sprintf(format, v...))
}
}
func (l *Logger) Warn(v ...interface{}) {
if Lwarn&l.flag != 0 {
l.Output(Lwarn, 2, fmt.Sprintf(smartFormat(v...), v...))
}
}
// error
func (l *Logger) Errorf(format string, v ...interface{}) {
if Lerror&l.flag != 0 {
l.Output(Lerror, 2, fmt.Sprintf(format, v...)+CallerStack())
}
}
func (l *Logger) Error(v ...interface{}) {
if Lerror&l.flag != 0 {
l.Output(Lerror, 2, fmt.Sprintf(smartFormat(v...), v...)+CallerStack())
}
}
// fatal
func (l *Logger) Fatalf(format string, v ...interface{}) {
l.Output(Lfatal, 2, fmt.Sprintf(format, v...))
os.Exit(1)
}
func (l *Logger) Fatal(v ...interface{}) {
l.Output(Lfatal, 2, fmt.Sprintf(smartFormat(v...), v...))
os.Exit(1)
}
func (l *Logger) Breakpoint() {
l.Output(Ldebug, 3, fmt.Sprintln("breakpoint"))
}
// 设置日志目录
func (l *Logger) SetLogDir(dir string) {
l.mu.Lock()
defer l.mu.Unlock()
l.dir = dir
}
// 设置日志对象名称
func (l *Logger) SetObj(obj string) {
l.mu.Lock()
defer l.mu.Unlock()
l.obj = obj
}
// 改变日志输出writer
func (l *Logger) SetOutput(out io.Writer) {
l.mu.Lock()
defer l.mu.Unlock()
l.out = out
}
// 设置日志等级
func (l *Logger) SetLevel(lvl int) {
l.mu.Lock()
defer l.mu.Unlock()
var i uint
for i = 0; i < uint(len(levelMaps)); i++ {
if lvl&1 != 0 {
break
}
lvl >>= 1
}
l.flag = (l.flag >> i) | (Lall >> i)
l.flag <<= i
}
// standard wrapper
var Std = New(LogOption{Out: os.Stdout, Flag: LstdFlags})
func Printf(format string, v ...interface{}) {
Std.Output(Linfo, 2, fmt.Sprintf(format, v...))
}
func Print(v ...interface{}) {
Std.Output(Linfo, 2, fmt.Sprintf(smartFormat(v...), v...))
}
func Debugf(format string, v ...interface{}) {
if Ldebug&Std.flag != 0 {
Std.Output(Ldebug, 2, fmt.Sprintf(format, v...))
}
}
func Debug(v ...interface{}) {
if Ldebug&Std.flag != 0 {
Std.Output(Ldebug, 2, fmt.Sprintf(smartFormat(v...), v...))
}
}
func Infof(format string, v ...interface{}) {
if Linfo&Std.flag != 0 {
Std.Output(Linfo, 2, fmt.Sprintf(format, v...))
}
}
func Info(v ...interface{}) {
if Linfo&Std.flag != 0 {
Std.Output(Linfo, 2, fmt.Sprintf(smartFormat(v...), v...))
}
}
func Warnf(format string, v ...interface{}) {
if Lwarn&Std.flag != 0 {
Std.Output(Lwarn, 2, fmt.Sprintf(format, v...))
}
}
func Warn(v ...interface{}) {
if Lwarn&Std.flag != 0 {
Std.Output(Lwarn, 2, fmt.Sprintf(smartFormat(v...), v...))
}
}
func Errorf(format string, v ...interface{}) {
if Lerror&Std.flag != 0 {
Std.Output(Lerror, 2, fmt.Sprintf(format, v...)+CallerStack())
}
}
func Error(v ...interface{}) {
if Lerror&Std.flag != 0 {
Std.Output(Lerror, 2, fmt.Sprintf(smartFormat(v...), v...)+CallerStack())
}
}
func Fatalf(format string, v ...interface{}) {
Std.Output(Lfatal, 2, fmt.Sprintf(format, v...)+CallerStack())
os.Exit(1)
}
func Fatal(v ...interface{}) {
Std.Output(Lfatal, 2, fmt.Sprintf(smartFormat(v...), v...)+CallerStack())
os.Exit(1)
}
func Breakpoint() {
Std.Breakpoint()
}
func SetLevel(lvl int) {
Std.SetLevel(lvl)
}
func SetOutput(w io.Writer) {
Std.SetOutput(w)
}
func SetObj(obj string) {
Std.SetObj(obj)
}
///////////////////////////////////////////////////////////////////////////////////////////
func smartFormat(v ...interface{}) string {
format := ""
for i := 0; i < len(v); i++ {
format += " %v"
}
format += "\n"
return format
}
// Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding.
func itoa(buf *[]byte, i int, wid int) {
// Assemble decimal in reverse order.
var b [20]byte
bp := len(b) - 1
for i >= 10 || wid > 1 {
wid--
q := i / 10
b[bp] = byte('0' + i - q*10)
bp--
i = q
}
// i < 10
b[bp] = byte('0' + i)
*buf = append(*buf, b[bp:]...)
}
const (
Gray = uint8(iota + 90)
Red
Green
Yellow
Blue
Magenta
)
// getColorLevel returns colored level string by given level.
func getColorLevel(level string) string {
level = strings.ToUpper(level)
switch level {
case "DEBUG":
return fmt.Sprintf("\033[%dm[%5s]\033[0m", Green, level)
case "INFO":
return fmt.Sprintf("\033[%dm[%5s]\033[0m", Blue, level)
case "WARN":
return fmt.Sprintf("\033[%dm[%5s]\033[0m", Magenta, level)
case "ERROR":
return fmt.Sprintf("\033[%dm[%5s]\033[0m", Yellow, level)
case "FATAL":
return fmt.Sprintf("\033[%dm[%5s]\033[0m", Red, level)
default:
return level
}
}
func CallerStack() string {
var caller_str string
for skip := 2; ; skip++ {
// 获取调用者的信息
pc, file, line, ok := runtime.Caller(skip)
if !ok {
break
}
func_name := runtime.FuncForPC(pc).Name()
caller_str += "Func : " + func_name + "\nFile:" + file + ":" + fmt.Sprint(line) + "\n"
}
return caller_str
}

107
vendor/github.com/deepzz0/logd/logd_test.go generated vendored Normal file
View File

@@ -0,0 +1,107 @@
package logd
import (
"log"
"os"
"testing"
)
func TestLog(t *testing.T) {
Printf("Printf: foo\n")
Print("Print: foo")
SetLevel(Ldebug)
Debugf("Debugf: foo\n")
Debug("Debug: foo")
Infof("Infof: foo\n")
Info("Info: foo")
Errorf("Errorf: foo\n")
Error("Error: foo")
SetLevel(Lerror)
Debugf("Debugf: foo\n")
Debug("Debug: foo")
Infof("Infof: foo\n")
Info("Info: foo")
Errorf("Errorf: foo\n")
Error("Error: foo")
}
func BenchmarkLogFileChan(b *testing.B) {
log := New(LogOption{
Flag: LAsync | Ldate | Ltime | Lshortfile,
LogDir: "testdata",
ChannelLen: 1000,
})
for i := 0; i < b.N; i++ {
log.Print("testing this is a testing about benchmark")
}
log.WaitFlush()
}
func BenchmarkLogFile(b *testing.B) {
f, _ := os.OpenFile("testdata/onlyfile.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
log := New(LogOption{
Out: f,
Flag: Ldate | Ltime | Lshortfile,
LogDir: "testdata",
ChannelLen: 1000,
})
for i := 0; i < b.N; i++ {
log.Print("testing this is a testing about benchmark")
}
log.WaitFlush()
}
func BenchmarkStandardFile(b *testing.B) {
f, _ := os.OpenFile("testdata/logfile.log", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
log := log.New(f, "", log.LstdFlags)
for i := 0; i < b.N; i++ {
log.Print("testing this is a testing about benchmark")
}
}
func BenchmarkLogFileChanMillion(b *testing.B) {
log := New(LogOption{
Flag: LAsync | Ldate | Ltime | Lshortfile,
LogDir: "testdata",
ChannelLen: 1000,
})
b.N = 1000000
for i := 0; i < b.N; i++ {
log.Print("testing this is a testing about benchmark")
}
log.WaitFlush()
}
func BenchmarkLogFileMillion(b *testing.B) {
f, _ := os.OpenFile("testdata/onlyfilemillion.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
log := New(LogOption{
Out: f,
Flag: Ldate | Ltime | Lshortfile,
LogDir: "testdata",
ChannelLen: 1000,
})
b.N = 1000000
for i := 0; i < b.N; i++ {
log.Print("testing this is a testing about benchmark")
}
log.WaitFlush()
}
func BenchmarkStandardFileMillion(b *testing.B) {
f, _ := os.OpenFile("testdata/logfilemillion.log", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
log := log.New(f, "", log.LstdFlags)
b.N = 1000000
for i := 0; i < b.N; i++ {
log.Print("testing this is a testing about benchmark")
}
}

80
vendor/github.com/deepzz0/logd/mail.go generated vendored Normal file
View File

@@ -0,0 +1,80 @@
package logd
import (
"crypto/tls"
"fmt"
"net/smtp"
"strings"
)
type Emailer interface {
SendMail(fromname string, msg []byte) error
}
type Smtp struct {
From string // 发件箱number@qq.com
Key string // 发件密钥peerdmnoqirqbiaa
Host string // 主机地址smtp.example.com
Port string // 主机端口465
To []string // 发送给object@163.com
Subject string // 标题:警告邮件[goblog]
}
func (s *Smtp) SendMail(fromname string, msg []byte) error {
// 新建连接
conn, err := tls.Dial("tcp", s.Host+":"+s.Port, nil)
if err != nil {
return err
}
// 新建客户端
client, err := smtp.NewClient(conn, s.Host)
if err != nil {
return err
}
// 获取授权
auth := smtp.PlainAuth("", s.From, s.Key, s.Host)
if err = client.Auth(auth); err != nil {
return err
}
// 向服务器发送MAIL命令
if err = client.Mail(s.From); err != nil {
return err
}
// 准备数据
str := fmt.Sprint(
"To:", strings.Join(s.To, ","),
"\r\nFrom:", fmt.Sprintf("%s<%s>", fromname, s.From),
"\r\nSubject:", s.Subject,
"\r\n", "Content-Type:text/plain;charset=UTF-8",
"\r\n\r\n",
)
data := make([]byte, len(str)+len(msg))
copy(data, []byte(str))
copy(data[len(str):], msg)
// RCPT
for _, d := range s.To {
if err := client.Rcpt(d); err != nil {
return err
}
}
// 获取WriteCloser
wc, err := client.Data()
if err != nil {
return err
}
// 写入数据
_, err = wc.Write(data)
if err != nil {
return err
}
wc.Close()
return client.Quit()
}

20
vendor/github.com/deepzz0/logd/mail_test.go generated vendored Normal file
View File

@@ -0,0 +1,20 @@
// Package logd provides ...
package logd
import "testing"
func TestSmtpSendMail(t *testing.T) {
s := &Smtp{
From: "120735581@qq.com",
Key: "peerdmnoqirqbiaa",
Host: "smtp.qq.com",
Port: "465",
To: []string{"a120735581@foxmail.com"},
Subject: "test email from logd",
}
err := s.SendMail("test", []byte("hello world"))
if err != nil {
t.Error(err)
}
}

View File

@@ -370,6 +370,10 @@ func (c *conn) writeCommand(cmd string, args []interface{}) (err error) {
} }
case nil: case nil:
err = c.writeString("") err = c.writeString("")
case Argument:
var buf bytes.Buffer
fmt.Fprint(&buf, arg.RedisArg())
err = c.writeBytes(buf.Bytes())
default: default:
var buf bytes.Buffer var buf bytes.Buffer
fmt.Fprint(&buf, arg) fmt.Fprint(&buf, arg)

View File

@@ -46,6 +46,14 @@ func dialTestConn(r io.Reader, w io.Writer) redis.DialOption {
}) })
} }
type durationArg struct {
time.Duration
}
func (t durationArg) RedisArg() interface{} {
return t.Seconds()
}
var writeTests = []struct { var writeTests = []struct {
args []interface{} args []interface{}
expected string expected string
@@ -82,6 +90,10 @@ var writeTests = []struct {
[]interface{}{"SET", "key", nil}, []interface{}{"SET", "key", nil},
"*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$0\r\n\r\n", "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$0\r\n\r\n",
}, },
{
[]interface{}{"SET", "key", durationArg{time.Minute}},
"*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$2\r\n60\r\n",
},
{ {
[]interface{}{"ECHO", true, false}, []interface{}{"ECHO", true, false},
"*3\r\n$4\r\nECHO\r\n$1\r\n1\r\n$1\r\n0\r\n", "*3\r\n$4\r\nECHO\r\n$1\r\n1\r\n$1\r\n0\r\n",
@@ -447,7 +459,7 @@ var dialErrors = []struct {
"localhost", "localhost",
"invalid redis URL scheme", "invalid redis URL scheme",
}, },
// The error message for invalid hosts is diffferent in different // The error message for invalid hosts is different in different
// versions of Go, so just check that there is an error message. // versions of Go, so just check that there is an error message.
{ {
"redis://weird url", "redis://weird url",

View File

@@ -437,8 +437,8 @@ func startGoroutines(p *redis.Pool, cmd string, args ...interface{}) chan error
go func() { go func() {
c := p.Get() c := p.Get()
_, err := c.Do(cmd, args...) _, err := c.Do(cmd, args...)
errs <- err
c.Close() c.Close()
errs <- err
}() }()
} }

View File

@@ -39,3 +39,21 @@ type Conn interface {
// Receive receives a single reply from the Redis server // Receive receives a single reply from the Redis server
Receive() (reply interface{}, err error) Receive() (reply interface{}, err error)
} }
// Argument is implemented by types which want to control how their value is
// interpreted when used as an argument to a redis command.
type Argument interface {
// RedisArg returns the interface that represents the value to be used
// in redis commands.
RedisArg() interface{}
}
// Scanner is implemented by types which want to control how their value is
// interpreted when read from redis.
type Scanner interface {
// RedisScan assigns a value from a redis value.
//
// An error should be returned if the value cannot be stored without
// loss of information.
RedisScan(src interface{}) error
}

View File

@@ -110,6 +110,25 @@ func convertAssignInt(d reflect.Value, s int64) (err error) {
} }
func convertAssignValue(d reflect.Value, s interface{}) (err error) { func convertAssignValue(d reflect.Value, s interface{}) (err error) {
if d.Kind() != reflect.Ptr {
if d.CanAddr() {
d2 := d.Addr()
if d2.CanInterface() {
if scanner, ok := d2.Interface().(Scanner); ok {
return scanner.RedisScan(s)
}
}
}
} else if d.CanInterface() {
// Already a reflect.Ptr
if d.IsNil() {
d.Set(reflect.New(d.Type().Elem()))
}
if scanner, ok := d.Interface().(Scanner); ok {
return scanner.RedisScan(s)
}
}
switch s := s.(type) { switch s := s.(type) {
case []byte: case []byte:
err = convertAssignBulkString(d, s) err = convertAssignBulkString(d, s)
@@ -135,11 +154,15 @@ func convertAssignArray(d reflect.Value, s []interface{}) error {
} }
func convertAssign(d interface{}, s interface{}) (err error) { func convertAssign(d interface{}, s interface{}) (err error) {
if scanner, ok := d.(Scanner); ok {
return scanner.RedisScan(s)
}
// Handle the most common destination types using type switches and // Handle the most common destination types using type switches and
// fall back to reflection for all other types. // fall back to reflection for all other types.
switch s := s.(type) { switch s := s.(type) {
case nil: case nil:
// ingore // ignore
case []byte: case []byte:
switch d := d.(type) { switch d := d.(type) {
case *string: case *string:
@@ -219,6 +242,8 @@ func convertAssign(d interface{}, s interface{}) (err error) {
// Scan copies from src to the values pointed at by dest. // Scan copies from src to the values pointed at by dest.
// //
// Scan uses RedisScan if available otherwise:
//
// The values pointed at by dest must be an integer, float, boolean, string, // The values pointed at by dest must be an integer, float, boolean, string,
// []byte, interface{} or slices of these types. Scan uses the standard strconv // []byte, interface{} or slices of these types. Scan uses the standard strconv
// package to convert bulk strings to numeric and boolean types. // package to convert bulk strings to numeric and boolean types.
@@ -359,6 +384,7 @@ var errScanStructValue = errors.New("redigo.ScanStruct: value must be non-nil po
// //
// Fields with the tag redis:"-" are ignored. // Fields with the tag redis:"-" are ignored.
// //
// Each field uses RedisScan if available otherwise:
// Integer, float, boolean, string and []byte fields are supported. Scan uses the // Integer, float, boolean, string and []byte fields are supported. Scan uses the
// standard strconv package to convert bulk string values to numeric and // standard strconv package to convert bulk string values to numeric and
// boolean types. // boolean types.

View File

@@ -19,10 +19,32 @@ import (
"math" "math"
"reflect" "reflect"
"testing" "testing"
"time"
"github.com/garyburd/redigo/redis" "github.com/garyburd/redigo/redis"
) )
type durationScan struct {
time.Duration `redis:"sd"`
}
func (t *durationScan) RedisScan(src interface{}) (err error) {
if t == nil {
return fmt.Errorf("nil pointer")
}
switch src := src.(type) {
case string:
t.Duration, err = time.ParseDuration(src)
case []byte:
t.Duration, err = time.ParseDuration(string(src))
case int64:
t.Duration = time.Duration(src)
default:
err = fmt.Errorf("cannot convert from %T to %T", src, t)
}
return err
}
var scanConversionTests = []struct { var scanConversionTests = []struct {
src interface{} src interface{}
dest interface{} dest interface{}
@@ -59,6 +81,11 @@ var scanConversionTests = []struct {
{[]interface{}{[]byte("1"), []byte("2")}, []float64{1, 2}}, {[]interface{}{[]byte("1"), []byte("2")}, []float64{1, 2}},
{[]interface{}{[]byte("1")}, []byte{1}}, {[]interface{}{[]byte("1")}, []byte{1}},
{[]interface{}{[]byte("1")}, []bool{true}}, {[]interface{}{[]byte("1")}, []bool{true}},
{"1m", durationScan{Duration: time.Minute}},
{[]byte("1m"), durationScan{Duration: time.Minute}},
{time.Minute.Nanoseconds(), durationScan{Duration: time.Minute}},
{[]interface{}{[]byte("1m")}, []durationScan{durationScan{Duration: time.Minute}}},
{[]interface{}{[]byte("1m")}, []*durationScan{&durationScan{Duration: time.Minute}}},
} }
func TestScanConversion(t *testing.T) { func TestScanConversion(t *testing.T) {
@@ -86,6 +113,8 @@ var scanConversionErrorTests = []struct {
{int64(-1), byte(0)}, {int64(-1), byte(0)},
{[]byte("junk"), false}, {[]byte("junk"), false},
{redis.Error("blah"), false}, {redis.Error("blah"), false},
{redis.Error("blah"), durationScan{Duration: time.Minute}},
{"invalid", durationScan{Duration: time.Minute}},
} }
func TestScanConversionError(t *testing.T) { func TestScanConversionError(t *testing.T) {
@@ -158,6 +187,8 @@ type s1 struct {
Bt bool Bt bool
Bf bool Bf bool
s0 s0
Sd durationScan `redis:"sd"`
Sdp *durationScan `redis:"sdp"`
} }
var scanStructTests = []struct { var scanStructTests = []struct {
@@ -166,8 +197,31 @@ var scanStructTests = []struct {
value interface{} value interface{}
}{ }{
{"basic", {"basic",
[]string{"i", "-1234", "u", "5678", "s", "hello", "p", "world", "b", "t", "Bt", "1", "Bf", "0", "X", "123", "y", "456"}, []string{
&s1{I: -1234, U: 5678, S: "hello", P: []byte("world"), B: true, Bt: true, Bf: false, s0: s0{X: 123, Y: 456}}, "i", "-1234",
"u", "5678",
"s", "hello",
"p", "world",
"b", "t",
"Bt", "1",
"Bf", "0",
"X", "123",
"y", "456",
"sd", "1m",
"sdp", "1m",
},
&s1{
I: -1234,
U: 5678,
S: "hello",
P: []byte("world"),
B: true,
Bt: true,
Bf: false,
s0: s0{X: 123, Y: 456},
Sd: durationScan{Duration: time.Minute},
Sdp: &durationScan{Duration: time.Minute},
},
}, },
} }

View File

@@ -47,6 +47,7 @@ package unix
#include <linux/filter.h> #include <linux/filter.h>
#include <linux/keyctl.h> #include <linux/keyctl.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/perf_event.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include <asm/termbits.h> #include <asm/termbits.h>
@@ -533,6 +534,8 @@ type Sigset_t C.sigset_t
const RNDGETENTCNT = C.RNDGETENTCNT const RNDGETENTCNT = C.RNDGETENTCNT
const PERF_IOC_FLAG_GROUP = C.PERF_IOC_FLAG_GROUP
// sysconf information // sysconf information
const _SC_PAGESIZE = C._SC_PAGESIZE const _SC_PAGESIZE = C._SC_PAGESIZE

View File

@@ -153,6 +153,7 @@ struct ltchars {
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/xattr.h>
#include <linux/if.h> #include <linux/if.h>
#include <linux/if_alg.h> #include <linux/if_alg.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
@@ -165,11 +166,13 @@ struct ltchars {
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/keyctl.h> #include <linux/keyctl.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/perf_event.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/seccomp.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include <linux/serial.h> #include <linux/serial.h>
@@ -374,7 +377,7 @@ ccflags="$@"
$2 == "IFNAMSIZ" || $2 == "IFNAMSIZ" ||
$2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ || $2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
$2 ~ /^SYSCTL_VERS/ || $2 ~ /^SYSCTL_VERS/ ||
$2 ~ /^(MS|MNT)_/ || $2 ~ /^(MS|MNT|UMOUNT)_/ ||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ || $2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
$2 ~ /^LINUX_REBOOT_CMD_/ || $2 ~ /^LINUX_REBOOT_CMD_/ ||
@@ -402,8 +405,11 @@ ccflags="$@"
$2 ~ /^GRND_/ || $2 ~ /^GRND_/ ||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ || $2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
$2 ~ /^KEYCTL_/ || $2 ~ /^KEYCTL_/ ||
$2 ~ /^PERF_EVENT_IOC_/ ||
$2 ~ /^SECCOMP_MODE_/ ||
$2 ~ /^SPLICE_/ || $2 ~ /^SPLICE_/ ||
$2 ~ /^(VM|VMADDR)_/ || $2 ~ /^(VM|VMADDR)_/ ||
$2 ~ /^XATTR_(CREATE|REPLACE)/ ||
$2 !~ "WMESGLEN" && $2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ || $2 ~ /^W[A-Z0-9]+$/ ||
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)} $2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}

View File

@@ -36,6 +36,20 @@ func Creat(path string, mode uint32) (fd int, err error) {
return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode) return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode)
} }
//sys fchmodat(dirfd int, path string, mode uint32) (err error)
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
// Linux fchmodat doesn't support the flags parameter. Mimick glibc's behavior
// and check the flags. Otherwise the mode would be applied to the symlink
// destination which is not what the user expects.
if flags&^AT_SYMLINK_NOFOLLOW != 0 {
return EINVAL
} else if flags&AT_SYMLINK_NOFOLLOW != 0 {
return EOPNOTSUPP
}
return fchmodat(dirfd, path, mode)
}
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
// ioctl itself should not be exposed directly, but additional get/set // ioctl itself should not be exposed directly, but additional get/set
@@ -47,6 +61,10 @@ func IoctlSetInt(fd int, req uint, value int) (err error) {
return ioctl(fd, req, uintptr(value)) return ioctl(fd, req, uintptr(value))
} }
func IoctlSetTermios(fd int, req uint, value *Termios) (err error) {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
// IoctlGetInt performs an ioctl operation which gets an integer value // IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number. // from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) { func IoctlGetInt(fd int, req uint) (int, error) {
@@ -55,6 +73,12 @@ func IoctlGetInt(fd int, req uint) (int, error) {
return value, err return value, err
} }
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) //sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
func Link(oldpath string, newpath string) (err error) { func Link(oldpath string, newpath string) (err error) {
@@ -1177,7 +1201,6 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) //sys Fallocate(fd int, mode uint32, off int64, len int64) (err error)
//sys Fchdir(fd int) (err error) //sys Fchdir(fd int) (err error)
//sys Fchmod(fd int, mode uint32) (err error) //sys Fchmod(fd int, mode uint32) (err error)
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
//sys fcntl(fd int, cmd int, arg int) (val int, err error) //sys fcntl(fd int, cmd int, arg int) (val int, err error)
//sys Fdatasync(fd int) (err error) //sys Fdatasync(fd int) (err error)

View File

@@ -15,6 +15,32 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
func TestFchmodat(t *testing.T) {
defer chtmpdir(t)()
touch(t, "file1")
os.Symlink("file1", "symlink1")
err := unix.Fchmodat(unix.AT_FDCWD, "symlink1", 0444, 0)
if err != nil {
t.Fatalf("Fchmodat: unexpected error: %v", err)
}
fi, err := os.Stat("file1")
if err != nil {
t.Fatal(err)
}
if fi.Mode() != 0444 {
t.Errorf("Fchmodat: failed to change mode: expected %v, got %v", 0444, fi.Mode())
}
err = unix.Fchmodat(unix.AT_FDCWD, "symlink1", 0444, unix.AT_SYMLINK_NOFOLLOW)
if err != unix.EOPNOTSUPP {
t.Fatalf("Fchmodat: unexpected error: %v, expected EOPNOTSUPP", err)
}
}
func TestIoctlGetInt(t *testing.T) { func TestIoctlGetInt(t *testing.T) {
f, err := os.Open("/dev/random") f, err := os.Open("/dev/random")
if err != nil { if err != nil {

View File

@@ -1056,6 +1056,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x2401
PERF_EVENT_IOC_ENABLE = 0x2400
PERF_EVENT_IOC_ID = 0x80042407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409
PERF_EVENT_IOC_PERIOD = 0x40082404
PERF_EVENT_IOC_REFRESH = 0x2402
PERF_EVENT_IOC_RESET = 0x2403
PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40042406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1393,6 +1403,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1752,6 +1765,7 @@ const (
TUNSETVNETBE = 0x400454de TUNSETVNETBE = 0x400454de
TUNSETVNETHDRSZ = 0x400454d8 TUNSETVNETHDRSZ = 0x400454d8
TUNSETVNETLE = 0x400454dc TUNSETVNETLE = 0x400454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x4 VEOF = 0x4
VEOL = 0xb VEOL = 0xb
@@ -1788,6 +1802,8 @@ const (
WORDSIZE = 0x20 WORDSIZE = 0x20
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1056,6 +1056,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x2401
PERF_EVENT_IOC_ENABLE = 0x2400
PERF_EVENT_IOC_ID = 0x80082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409
PERF_EVENT_IOC_PERIOD = 0x40082404
PERF_EVENT_IOC_REFRESH = 0x2402
PERF_EVENT_IOC_RESET = 0x2403
PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1394,6 +1404,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1753,6 +1766,7 @@ const (
TUNSETVNETBE = 0x400454de TUNSETVNETBE = 0x400454de
TUNSETVNETHDRSZ = 0x400454d8 TUNSETVNETHDRSZ = 0x400454d8
TUNSETVNETLE = 0x400454dc TUNSETVNETLE = 0x400454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x4 VEOF = 0x4
VEOL = 0xb VEOL = 0xb
@@ -1789,6 +1803,8 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1055,6 +1055,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x2401
PERF_EVENT_IOC_ENABLE = 0x2400
PERF_EVENT_IOC_ID = 0x80042407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409
PERF_EVENT_IOC_PERIOD = 0x40082404
PERF_EVENT_IOC_REFRESH = 0x2402
PERF_EVENT_IOC_RESET = 0x2403
PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40042406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1398,6 +1408,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1757,6 +1770,7 @@ const (
TUNSETVNETBE = 0x400454de TUNSETVNETBE = 0x400454de
TUNSETVNETHDRSZ = 0x400454d8 TUNSETVNETHDRSZ = 0x400454d8
TUNSETVNETLE = 0x400454dc TUNSETVNETLE = 0x400454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x4 VEOF = 0x4
VEOL = 0xb VEOL = 0xb
@@ -1793,6 +1807,8 @@ const (
WORDSIZE = 0x20 WORDSIZE = 0x20
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1056,6 +1056,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x2401
PERF_EVENT_IOC_ENABLE = 0x2400
PERF_EVENT_IOC_ID = 0x80082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409
PERF_EVENT_IOC_PERIOD = 0x40082404
PERF_EVENT_IOC_REFRESH = 0x2402
PERF_EVENT_IOC_RESET = 0x2403
PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1383,6 +1393,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1742,6 +1755,7 @@ const (
TUNSETVNETBE = 0x400454de TUNSETVNETBE = 0x400454de
TUNSETVNETHDRSZ = 0x400454d8 TUNSETVNETHDRSZ = 0x400454d8
TUNSETVNETLE = 0x400454dc TUNSETVNETLE = 0x400454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x4 VEOF = 0x4
VEOL = 0xb VEOL = 0xb
@@ -1778,6 +1792,8 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1056,6 +1056,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x20002401
PERF_EVENT_IOC_ENABLE = 0x20002400
PERF_EVENT_IOC_ID = 0x40042407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
PERF_EVENT_IOC_PERIOD = 0x80082404
PERF_EVENT_IOC_REFRESH = 0x20002402
PERF_EVENT_IOC_RESET = 0x20002403
PERF_EVENT_IOC_SET_BPF = 0x80042408
PERF_EVENT_IOC_SET_FILTER = 0x80042406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1395,6 +1405,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1756,6 +1769,7 @@ const (
TUNSETVNETBE = 0x800454de TUNSETVNETBE = 0x800454de
TUNSETVNETHDRSZ = 0x800454d8 TUNSETVNETHDRSZ = 0x800454d8
TUNSETVNETLE = 0x800454dc TUNSETVNETLE = 0x800454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x10 VEOF = 0x10
VEOL = 0x11 VEOL = 0x11
@@ -1793,6 +1807,8 @@ const (
WORDSIZE = 0x20 WORDSIZE = 0x20
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1056,6 +1056,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x20002401
PERF_EVENT_IOC_ENABLE = 0x20002400
PERF_EVENT_IOC_ID = 0x40082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
PERF_EVENT_IOC_PERIOD = 0x80082404
PERF_EVENT_IOC_REFRESH = 0x20002402
PERF_EVENT_IOC_RESET = 0x20002403
PERF_EVENT_IOC_SET_BPF = 0x80042408
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1395,6 +1405,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1756,6 +1769,7 @@ const (
TUNSETVNETBE = 0x800454de TUNSETVNETBE = 0x800454de
TUNSETVNETHDRSZ = 0x800454d8 TUNSETVNETHDRSZ = 0x800454d8
TUNSETVNETLE = 0x800454dc TUNSETVNETLE = 0x800454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x10 VEOF = 0x10
VEOL = 0x11 VEOL = 0x11
@@ -1793,6 +1807,8 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1056,6 +1056,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x20002401
PERF_EVENT_IOC_ENABLE = 0x20002400
PERF_EVENT_IOC_ID = 0x40082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
PERF_EVENT_IOC_PERIOD = 0x80082404
PERF_EVENT_IOC_REFRESH = 0x20002402
PERF_EVENT_IOC_RESET = 0x20002403
PERF_EVENT_IOC_SET_BPF = 0x80042408
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1395,6 +1405,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1756,6 +1769,7 @@ const (
TUNSETVNETBE = 0x800454de TUNSETVNETBE = 0x800454de
TUNSETVNETHDRSZ = 0x800454d8 TUNSETVNETHDRSZ = 0x800454d8
TUNSETVNETLE = 0x800454dc TUNSETVNETLE = 0x800454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x10 VEOF = 0x10
VEOL = 0x11 VEOL = 0x11
@@ -1793,6 +1807,8 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1056,6 +1056,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x20002401
PERF_EVENT_IOC_ENABLE = 0x20002400
PERF_EVENT_IOC_ID = 0x40042407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
PERF_EVENT_IOC_PERIOD = 0x80082404
PERF_EVENT_IOC_REFRESH = 0x20002402
PERF_EVENT_IOC_RESET = 0x20002403
PERF_EVENT_IOC_SET_BPF = 0x80042408
PERF_EVENT_IOC_SET_FILTER = 0x80042406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1395,6 +1405,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1756,6 +1769,7 @@ const (
TUNSETVNETBE = 0x800454de TUNSETVNETBE = 0x800454de
TUNSETVNETHDRSZ = 0x800454d8 TUNSETVNETHDRSZ = 0x800454d8
TUNSETVNETLE = 0x800454dc TUNSETVNETLE = 0x800454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x10 VEOF = 0x10
VEOL = 0x11 VEOL = 0x11
@@ -1793,6 +1807,8 @@ const (
WORDSIZE = 0x20 WORDSIZE = 0x20
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -1057,6 +1057,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x2000 PARODD = 0x2000
PENDIN = 0x20000000 PENDIN = 0x20000000
PERF_EVENT_IOC_DISABLE = 0x20002401
PERF_EVENT_IOC_ENABLE = 0x20002400
PERF_EVENT_IOC_ID = 0x40082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
PERF_EVENT_IOC_PERIOD = 0x80082404
PERF_EVENT_IOC_REFRESH = 0x20002402
PERF_EVENT_IOC_RESET = 0x20002403
PERF_EVENT_IOC_SET_BPF = 0x80042408
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1451,6 +1461,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1814,6 +1827,7 @@ const (
TUNSETVNETBE = 0x800454de TUNSETVNETBE = 0x800454de
TUNSETVNETHDRSZ = 0x800454d8 TUNSETVNETHDRSZ = 0x800454d8
TUNSETVNETLE = 0x800454dc TUNSETVNETLE = 0x800454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0x10 VDISCARD = 0x10
VEOF = 0x4 VEOF = 0x4
VEOL = 0x6 VEOL = 0x6
@@ -1850,6 +1864,8 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4000 XCASE = 0x4000
XTABS = 0xc00 XTABS = 0xc00
) )

View File

@@ -1057,6 +1057,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x2000 PARODD = 0x2000
PENDIN = 0x20000000 PENDIN = 0x20000000
PERF_EVENT_IOC_DISABLE = 0x20002401
PERF_EVENT_IOC_ENABLE = 0x20002400
PERF_EVENT_IOC_ID = 0x40082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
PERF_EVENT_IOC_PERIOD = 0x80082404
PERF_EVENT_IOC_REFRESH = 0x20002402
PERF_EVENT_IOC_RESET = 0x20002403
PERF_EVENT_IOC_SET_BPF = 0x80042408
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1451,6 +1461,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1814,6 +1827,7 @@ const (
TUNSETVNETBE = 0x800454de TUNSETVNETBE = 0x800454de
TUNSETVNETHDRSZ = 0x800454d8 TUNSETVNETHDRSZ = 0x800454d8
TUNSETVNETLE = 0x800454dc TUNSETVNETLE = 0x800454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0x10 VDISCARD = 0x10
VEOF = 0x4 VEOF = 0x4
VEOL = 0x6 VEOL = 0x6
@@ -1850,6 +1864,8 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4000 XCASE = 0x4000
XTABS = 0xc00 XTABS = 0xc00
) )

View File

@@ -1055,6 +1055,16 @@ const (
PARMRK = 0x8 PARMRK = 0x8
PARODD = 0x200 PARODD = 0x200
PENDIN = 0x4000 PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x2401
PERF_EVENT_IOC_ENABLE = 0x2400
PERF_EVENT_IOC_ID = 0x80082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409
PERF_EVENT_IOC_PERIOD = 0x40082404
PERF_EVENT_IOC_REFRESH = 0x2402
PERF_EVENT_IOC_RESET = 0x2403
PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PRIO_PGRP = 0x1 PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0 PRIO_PROCESS = 0x0
PRIO_USER = 0x2 PRIO_USER = 0x2
@@ -1455,6 +1465,9 @@ const (
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPNS = 0x23 SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29 SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0 SHUT_RD = 0x0
SHUT_RDWR = 0x2 SHUT_RDWR = 0x2
SHUT_WR = 0x1 SHUT_WR = 0x1
@@ -1814,6 +1827,7 @@ const (
TUNSETVNETBE = 0x400454de TUNSETVNETBE = 0x400454de
TUNSETVNETHDRSZ = 0x400454d8 TUNSETVNETHDRSZ = 0x400454d8
TUNSETVNETLE = 0x400454dc TUNSETVNETLE = 0x400454dc
UMOUNT_NOFOLLOW = 0x8
VDISCARD = 0xd VDISCARD = 0xd
VEOF = 0x4 VEOF = 0x4
VEOL = 0xb VEOL = 0xb
@@ -1850,6 +1864,8 @@ const (
WORDSIZE = 0x40 WORDSIZE = 0x40
WSTOPPED = 0x2 WSTOPPED = 0x2
WUNTRACED = 0x2 WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4 XCASE = 0x4
XTABS = 0x1800 XTABS = 0x1800
) )

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -14,6 +14,21 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) { func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 { if e1 != 0 {
@@ -574,21 +589,6 @@ func Fchmod(fd int, mode uint32) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte var _p0 *byte
_p0, err = BytePtrFromString(path) _p0, err = BytePtrFromString(path)

View File

@@ -662,6 +662,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x80045200 const RNDGETENTCNT = 0x80045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -680,6 +680,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x80045200 const RNDGETENTCNT = 0x80045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -651,6 +651,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x80045200 const RNDGETENTCNT = 0x80045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -659,6 +659,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x80045200 const RNDGETENTCNT = 0x80045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -656,6 +656,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x40045200 const RNDGETENTCNT = 0x40045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -661,6 +661,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x40045200 const RNDGETENTCNT = 0x40045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -661,6 +661,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x40045200 const RNDGETENTCNT = 0x40045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -656,6 +656,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x40045200 const RNDGETENTCNT = 0x40045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -669,6 +669,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x40045200 const RNDGETENTCNT = 0x40045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -669,6 +669,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x40045200 const RNDGETENTCNT = 0x40045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -686,6 +686,8 @@ type Sigset_t struct {
const RNDGETENTCNT = 0x80045200 const RNDGETENTCNT = 0x80045200
const PERF_IOC_FLAG_GROUP = 0x1
const _SC_PAGESIZE = 0x1e const _SC_PAGESIZE = 0x1e
type Termios struct { type Termios struct {

View File

@@ -160,7 +160,6 @@ func (p *Proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
default: default:
panic("Call " + p.Name + " with too many arguments " + itoa(len(a)) + ".") panic("Call " + p.Name + " with too many arguments " + itoa(len(a)) + ".")
} }
return
} }
// A LazyDLL implements access to a single DLL. // A LazyDLL implements access to a single DLL.

26
vendor/golang.org/x/sys/windows/memory_windows.go generated vendored Normal file
View File

@@ -0,0 +1,26 @@
// Copyright 2017 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.
package windows
const (
MEM_COMMIT = 0x00001000
MEM_RESERVE = 0x00002000
MEM_DECOMMIT = 0x00004000
MEM_RELEASE = 0x00008000
MEM_RESET = 0x00080000
MEM_TOP_DOWN = 0x00100000
MEM_WRITE_WATCH = 0x00200000
MEM_PHYSICAL = 0x00400000
MEM_RESET_UNDO = 0x01000000
MEM_LARGE_PAGES = 0x20000000
PAGE_NOACCESS = 0x01
PAGE_READONLY = 0x02
PAGE_READWRITE = 0x04
PAGE_WRITECOPY = 0x08
PAGE_EXECUTE_READ = 0x20
PAGE_EXECUTE_READWRITE = 0x40
PAGE_EXECUTE_WRITECOPY = 0x80
)

View File

@@ -336,7 +336,7 @@ func testGetValue(t *testing.T, k registry.Key, test ValueTest, size int) {
// read data with short buffer // read data with short buffer
gotsize, gottype, err = k.GetValue(test.Name, make([]byte, size-1)) gotsize, gottype, err = k.GetValue(test.Name, make([]byte, size-1))
if err == nil { if err == nil {
t.Errorf("GetValue(%s, [%d]byte) should fail, but suceeded", test.Name, size-1) t.Errorf("GetValue(%s, [%d]byte) should fail, but succeeded", test.Name, size-1)
return return
} }
if err != registry.ErrShortBuffer { if err != registry.ErrShortBuffer {

View File

@@ -95,6 +95,8 @@ const (
SERVICE_CONFIG_FAILURE_ACTIONS = 2 SERVICE_CONFIG_FAILURE_ACTIONS = 2
NO_ERROR = 0 NO_ERROR = 0
SC_ENUM_PROCESS_INFO = 0
) )
type SERVICE_STATUS struct { type SERVICE_STATUS struct {
@@ -128,6 +130,24 @@ type SERVICE_DESCRIPTION struct {
Description *uint16 Description *uint16
} }
type SERVICE_STATUS_PROCESS struct {
ServiceType uint32
CurrentState uint32
ControlsAccepted uint32
Win32ExitCode uint32
ServiceSpecificExitCode uint32
CheckPoint uint32
WaitHint uint32
ProcessId uint32
ServiceFlags uint32
}
type ENUM_SERVICE_STATUS_PROCESS struct {
ServiceName *uint16
DisplayName *uint16
ServiceStatusProcess SERVICE_STATUS_PROCESS
}
//sys CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle //sys CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle
//sys CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) [failretval==0] = advapi32.CreateServiceW //sys CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) [failretval==0] = advapi32.CreateServiceW
//sys OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW //sys OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW
@@ -141,3 +161,4 @@ type SERVICE_DESCRIPTION struct {
//sys QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfigW //sys QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfigW
//sys ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) = advapi32.ChangeServiceConfig2W //sys ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) = advapi32.ChangeServiceConfig2W
//sys QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfig2W //sys QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfig2W
//sys EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) = advapi32.EnumServicesStatusExW

View File

@@ -14,6 +14,7 @@ package mgr
import ( import (
"syscall" "syscall"
"unicode/utf16" "unicode/utf16"
"unsafe"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
@@ -119,3 +120,43 @@ func (m *Mgr) OpenService(name string) (*Service, error) {
} }
return &Service{Name: name, Handle: h}, nil return &Service{Name: name, Handle: h}, nil
} }
// ListServices enumerates services in the specified
// service control manager database m.
// If the caller does not have the SERVICE_QUERY_STATUS
// access right to a service, the service is silently
// omitted from the list of services returned.
func (m *Mgr) ListServices() ([]string, error) {
var err error
var bytesNeeded, servicesReturned uint32
var buf []byte
for {
var p *byte
if len(buf) > 0 {
p = &buf[0]
}
err = windows.EnumServicesStatusEx(m.Handle, windows.SC_ENUM_PROCESS_INFO,
windows.SERVICE_WIN32, windows.SERVICE_STATE_ALL,
p, uint32(len(buf)), &bytesNeeded, &servicesReturned, nil, nil)
if err == nil {
break
}
if err != syscall.ERROR_MORE_DATA {
return nil, err
}
if bytesNeeded <= uint32(len(buf)) {
return nil, err
}
buf = make([]byte, bytesNeeded)
}
if servicesReturned == 0 {
return nil, nil
}
services := (*[1 << 20]windows.ENUM_SERVICE_STATUS_PROCESS)(unsafe.Pointer(&buf[0]))[:servicesReturned]
var names []string
for _, s := range services {
name := syscall.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(s.ServiceName))[:])
names = append(names, name)
}
return names, nil
}

View File

@@ -150,5 +150,20 @@ func TestMyService(t *testing.T) {
testConfig(t, s, c) testConfig(t, s, c)
svcnames, err := m.ListServices()
if err != nil {
t.Fatalf("ListServices failed: %v", err)
}
var myserviceIsInstalled bool
for _, sn := range svcnames {
if sn == name {
myserviceIsInstalled = true
break
}
}
if !myserviceIsInstalled {
t.Errorf("ListServices failed to find %q service", name)
}
remove(t, s) remove(t, s)
} }

View File

@@ -15,8 +15,6 @@ import (
// TODO(brainman): Use EnumDependentServices to enumerate dependent services. // TODO(brainman): Use EnumDependentServices to enumerate dependent services.
// TODO(brainman): Use EnumServicesStatus to enumerate services in the specified service control manager database.
// Service is used to access Windows service. // Service is used to access Windows service.
type Service struct { type Service struct {
Name string Name string

View File

@@ -56,9 +56,14 @@ const (
type Accepted uint32 type Accepted uint32
const ( const (
AcceptStop = Accepted(windows.SERVICE_ACCEPT_STOP) AcceptStop = Accepted(windows.SERVICE_ACCEPT_STOP)
AcceptShutdown = Accepted(windows.SERVICE_ACCEPT_SHUTDOWN) AcceptShutdown = Accepted(windows.SERVICE_ACCEPT_SHUTDOWN)
AcceptPauseAndContinue = Accepted(windows.SERVICE_ACCEPT_PAUSE_CONTINUE) AcceptPauseAndContinue = Accepted(windows.SERVICE_ACCEPT_PAUSE_CONTINUE)
AcceptParamChange = Accepted(windows.SERVICE_ACCEPT_PARAMCHANGE)
AcceptNetBindChange = Accepted(windows.SERVICE_ACCEPT_NETBINDCHANGE)
AcceptHardwareProfileChange = Accepted(windows.SERVICE_ACCEPT_HARDWAREPROFILECHANGE)
AcceptPowerEvent = Accepted(windows.SERVICE_ACCEPT_POWEREVENT)
AcceptSessionChange = Accepted(windows.SERVICE_ACCEPT_SESSIONCHANGE)
) )
// Status combines State and Accepted commands to fully describe running service. // Status combines State and Accepted commands to fully describe running service.
@@ -180,6 +185,21 @@ func (s *service) updateStatus(status *Status, ec *exitCode) error {
if status.Accepts&AcceptPauseAndContinue != 0 { if status.Accepts&AcceptPauseAndContinue != 0 {
t.ControlsAccepted |= windows.SERVICE_ACCEPT_PAUSE_CONTINUE t.ControlsAccepted |= windows.SERVICE_ACCEPT_PAUSE_CONTINUE
} }
if status.Accepts&AcceptParamChange != 0 {
t.ControlsAccepted |= windows.SERVICE_ACCEPT_PARAMCHANGE
}
if status.Accepts&AcceptNetBindChange != 0 {
t.ControlsAccepted |= windows.SERVICE_ACCEPT_NETBINDCHANGE
}
if status.Accepts&AcceptHardwareProfileChange != 0 {
t.ControlsAccepted |= windows.SERVICE_ACCEPT_HARDWAREPROFILECHANGE
}
if status.Accepts&AcceptPowerEvent != 0 {
t.ControlsAccepted |= windows.SERVICE_ACCEPT_POWEREVENT
}
if status.Accepts&AcceptSessionChange != 0 {
t.ControlsAccepted |= windows.SERVICE_ACCEPT_SESSIONCHANGE
}
if ec.errno == 0 { if ec.errno == 0 {
t.Win32ExitCode = windows.NO_ERROR t.Win32ExitCode = windows.NO_ERROR
t.ServiceSpecificExitCode = windows.NO_ERROR t.ServiceSpecificExitCode = windows.NO_ERROR

View File

@@ -154,6 +154,9 @@ func NewCallbackCDecl(fn interface{}) uintptr
//sys FlushViewOfFile(addr uintptr, length uintptr) (err error) //sys FlushViewOfFile(addr uintptr, length uintptr) (err error)
//sys VirtualLock(addr uintptr, length uintptr) (err error) //sys VirtualLock(addr uintptr, length uintptr) (err error)
//sys VirtualUnlock(addr uintptr, length uintptr) (err error) //sys VirtualUnlock(addr uintptr, length uintptr) (err error)
//sys VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) = kernel32.VirtualAlloc
//sys VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) = kernel32.VirtualFree
//sys VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) = kernel32.VirtualProtect
//sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile //sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile
//sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW //sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW
//sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW //sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW

View File

@@ -64,6 +64,7 @@ var (
procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW") procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W") procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W") procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
procGetLastError = modkernel32.NewProc("GetLastError") procGetLastError = modkernel32.NewProc("GetLastError")
procLoadLibraryW = modkernel32.NewProc("LoadLibraryW") procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW") procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
@@ -138,6 +139,9 @@ var (
procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile") procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
procVirtualLock = modkernel32.NewProc("VirtualLock") procVirtualLock = modkernel32.NewProc("VirtualLock")
procVirtualUnlock = modkernel32.NewProc("VirtualUnlock") procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
procVirtualFree = modkernel32.NewProc("VirtualFree")
procVirtualProtect = modkernel32.NewProc("VirtualProtect")
procTransmitFile = modmswsock.NewProc("TransmitFile") procTransmitFile = modmswsock.NewProc("TransmitFile")
procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW") procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW") procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
@@ -430,6 +434,18 @@ func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize
return return
} }
func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
r1, _, e1 := syscall.Syscall12(procEnumServicesStatusExW.Addr(), 10, uintptr(mgr), uintptr(infoLevel), uintptr(serviceType), uintptr(serviceState), uintptr(unsafe.Pointer(services)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), uintptr(unsafe.Pointer(servicesReturned)), uintptr(unsafe.Pointer(resumeHandle)), uintptr(unsafe.Pointer(groupName)), 0, 0)
if r1 == 0 {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func GetLastError() (lasterr error) { func GetLastError() (lasterr error) {
r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0) r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
if r0 != 0 { if r0 != 0 {
@@ -1371,6 +1387,43 @@ func VirtualUnlock(addr uintptr, length uintptr) (err error) {
return return
} }
func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
value = uintptr(r0)
if value == 0 {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
if r1 == 0 {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
if r1 == 0 {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
}
return
}
func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) { func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
r1, _, e1 := syscall.Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0) r1, _, e1 := syscall.Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
if r1 == 0 { if r1 == 0 {

View File

@@ -165,13 +165,6 @@ const (
PROCESS_QUERY_INFORMATION = 0x00000400 PROCESS_QUERY_INFORMATION = 0x00000400
SYNCHRONIZE = 0x00100000 SYNCHRONIZE = 0x00100000
PAGE_READONLY = 0x02
PAGE_READWRITE = 0x04
PAGE_WRITECOPY = 0x08
PAGE_EXECUTE_READ = 0x20
PAGE_EXECUTE_READWRITE = 0x40
PAGE_EXECUTE_WRITECOPY = 0x80
FILE_MAP_COPY = 0x01 FILE_MAP_COPY = 0x01
FILE_MAP_WRITE = 0x02 FILE_MAP_WRITE = 0x02
FILE_MAP_READ = 0x04 FILE_MAP_READ = 0x04

View File

@@ -8,20 +8,11 @@ import (
) )
// CreateTimestampAntileechURL 构建带时间戳防盗链的链接 // CreateTimestampAntileechURL 构建带时间戳防盗链的链接
// host需要加上 "http://" 或 "https://"
// encryptKey 七牛防盗链key // encryptKey 七牛防盗链key
func CreateTimestampAntileechURL(host, fileName string, queryStr url.Values, encryptKey string, durationInSeconds int64) (antileechURL string, err error) { func CreateTimestampAntileechURL(urlStr string, encryptKey string, durationInSeconds int64) (antileechURL string, err error) {
var urlStr string u, err := url.Parse(urlStr)
if queryStr != nil { if err != nil {
urlStr = fmt.Sprintf("%s/%s?%s", host, fileName, queryStr.Encode())
} else {
urlStr = fmt.Sprintf("%s/%s", host, fileName)
}
u, parseErr := url.Parse(urlStr)
if parseErr != nil {
err = parseErr
return return
} }
@@ -29,13 +20,16 @@ func CreateTimestampAntileechURL(host, fileName string, queryStr url.Values, enc
toSignStr := fmt.Sprintf("%s%s%x", encryptKey, u.EscapedPath(), expireTime) toSignStr := fmt.Sprintf("%s%s%x", encryptKey, u.EscapedPath(), expireTime)
signedStr := fmt.Sprintf("%x", md5.Sum([]byte(toSignStr))) signedStr := fmt.Sprintf("%x", md5.Sum([]byte(toSignStr)))
q := u.Query() q := url.Values{}
q.Add("sign", signedStr) q.Add("sign", signedStr)
q.Add("t", fmt.Sprintf("%x", expireTime)) q.Add("t", fmt.Sprintf("%x", expireTime))
u.RawQuery = q.Encode()
antileechURL = fmt.Sprintf("%s://%s%s?%s", u.Scheme, u.Host, u.EscapedPath(), u.Query().Encode()) if u.RawQuery == "" {
antileechURL = u.String() + "?" + q.Encode()
} else {
antileechURL = u.String() + "&" + q.Encode()
}
return return
} }

View File

@@ -1,15 +1,12 @@
package cdn package cdn
import ( import (
"net/url"
"testing" "testing"
) )
func TestCreateTimestampAntiLeech(t *testing.T) { func TestCreateTimestampAntiLeech(t *testing.T) {
type args struct { type args struct {
host string urlStr string
fileName string
queryStr url.Values
encryptKey string encryptKey string
durationInSeconds int64 durationInSeconds int64
} }
@@ -21,11 +18,7 @@ func TestCreateTimestampAntiLeech(t *testing.T) {
{ {
name: "antileech_1", name: "antileech_1",
args: args{ args: args{
host: "http://www.abc.com", urlStr: "http://www.abc.com/abc.jpg?stat",
fileName: "abc.jpg",
queryStr: url.Values{
"x": {"9"},
},
encryptKey: "abc", encryptKey: "abc",
durationInSeconds: 20, durationInSeconds: 20,
}, },
@@ -34,7 +27,7 @@ func TestCreateTimestampAntiLeech(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
_, err := CreateTimestampAntileechURL(tt.args.host, tt.args.fileName, tt.args.queryStr, tt.args.encryptKey, tt.args.durationInSeconds) _, err := CreateTimestampAntileechURL(tt.args.urlStr, tt.args.encryptKey, tt.args.durationInSeconds)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("CreateTimestampAntiLeech() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("CreateTimestampAntiLeech() error = %v, wantErr %v", err, tt.wantErr)
return return