- update vendor

master
李光春 1 year ago
parent bda5c8a176
commit 8f245f20e4

@ -5,7 +5,7 @@ go 1.20
require (
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible
github.com/allegro/bigcache/v3 v3.1.0
github.com/aws/aws-sdk-go v1.44.168
github.com/aws/aws-sdk-go v1.44.170
github.com/aws/aws-sdk-go-v2/config v1.18.7
github.com/aws/aws-sdk-go-v2/service/s3 v1.29.6
github.com/baidubce/bce-sdk-go v0.9.139
@ -21,7 +21,7 @@ require (
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.22.11+incompatible
github.com/jasonlvhit/gocron v0.0.1
github.com/kamva/mgm/v3 v3.5.0
github.com/ks3sdklib/aws-sdk-go v1.1.8
github.com/ks3sdklib/aws-sdk-go v1.2.0
github.com/lib/pq v1.10.7
github.com/mitchellh/mapstructure v1.5.0
github.com/mvdan/xurls v1.1.0
@ -78,7 +78,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/clbanning/mxj v1.8.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
@ -117,7 +116,7 @@ require (
github.com/klauspost/compress v1.15.13 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@ -175,7 +174,7 @@ require (
k8s.io/kube-openapi v0.0.0-20221207184640-f3cff1453715 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
mellium.im/sasl v0.3.0 // indirect
mellium.im/sasl v0.3.1 // indirect
modernc.org/ccgo/v3 v3.16.8 // indirect
modernc.org/libc v1.16.19 // indirect
modernc.org/opt v0.1.3 // indirect

@ -36,8 +36,8 @@ github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6l
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.42.27/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc=
github.com/aws/aws-sdk-go v1.44.168 h1:/NNDLkjcgW8UrvAUk7QvQS9yzo/CFu9Zp4BCiPHoV+E=
github.com/aws/aws-sdk-go v1.44.168/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.44.170 h1:9dGTB7XRHzDB8+1NOIg/QS/DhCWgIM/iMC1dlZv42CE=
github.com/aws/aws-sdk-go v1.44.170/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/aws/aws-sdk-go-v2 v1.17.3 h1:shN7NlnVzvDUgPQ+1rLMSxY8OWRNDRYtiqe0p/PgrhY=
github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
@ -116,7 +116,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
@ -424,8 +423,8 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/ks3sdklib/aws-sdk-go v1.1.8 h1:j+7aw21UYgraHEPK2aaQaiz3l82gj89BfszxZ8z+4j8=
github.com/ks3sdklib/aws-sdk-go v1.1.8/go.mod h1:DVzr6V4XzDjdy+H+1ptuIDIy1MQgI+28SvUpOkJXJD8=
github.com/ks3sdklib/aws-sdk-go v1.2.0 h1:Hhe7Ku2gs/TykWy4hoSVTqlLu2p+AApeatKHysgRgVM=
github.com/ks3sdklib/aws-sdk-go v1.2.0/go.mod h1:DVzr6V4XzDjdy+H+1ptuIDIy1MQgI+28SvUpOkJXJD8=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
@ -455,8 +454,8 @@ github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
@ -1033,8 +1032,8 @@ k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
mellium.im/sasl v0.3.0 h1:0qoaTCTo5Py7u/g0cBIQZcMOgG/5LM71nshbXwznBh8=
mellium.im/sasl v0.3.0/go.mod h1:xm59PUYpZHhgQ9ZqoJ5QaCqzWMi8IeS49dhp6plPCzw=
mellium.im/sasl v0.3.1 h1:wE0LW6g7U83vhvxjC1IY8DnXM+EU095yeo8XClvCdfo=
mellium.im/sasl v0.3.1/go.mod h1:xm59PUYpZHhgQ9ZqoJ5QaCqzWMi8IeS49dhp6plPCzw=
modernc.org/b v1.0.2/go.mod h1:fVGfCIzkZw5RsuF2A2WHbJmY7FiMIq30nP4s52uWsoY=
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=

@ -33211,6 +33211,13 @@ var awsusgovPartition = partition{
},
},
},
"pi": service{
Endpoints: serviceEndpoints{
endpointKey{
Region: "us-gov-east-1",
}: endpoint{},
},
},
"pinpoint": service{
Defaults: endpointDefaults{
defaultKey{}: endpoint{

@ -5,4 +5,4 @@ package aws
const SDKName = "aws-sdk-go"
// SDKVersion is the version of this SDK
const SDKVersion = "1.44.168"
const SDKVersion = "1.44.170"

@ -13,10 +13,17 @@ import (
"github.com/aws/aws-sdk-go/private/protocol/json/jsonutil"
)
const (
awsQueryError = "x-amzn-query-error"
// A valid header example - "x-amzn-query-error": "<QueryErrorCode>;<ErrorType>"
awsQueryErrorPartsCount = 2
)
// UnmarshalTypedError provides unmarshaling errors API response errors
// for both typed and untyped errors.
type UnmarshalTypedError struct {
exceptions map[string]func(protocol.ResponseMetadata) error
queryExceptions map[string]func(protocol.ResponseMetadata, string) error
}
// NewUnmarshalTypedError returns an UnmarshalTypedError initialized for the
@ -24,6 +31,21 @@ type UnmarshalTypedError struct {
func NewUnmarshalTypedError(exceptions map[string]func(protocol.ResponseMetadata) error) *UnmarshalTypedError {
return &UnmarshalTypedError{
exceptions: exceptions,
queryExceptions: map[string]func(protocol.ResponseMetadata, string) error{},
}
}
func NewUnmarshalTypedErrorWithOptions(exceptions map[string]func(protocol.ResponseMetadata) error, optFns ...func(*UnmarshalTypedError)) *UnmarshalTypedError {
unmarshaledError := NewUnmarshalTypedError(exceptions)
for _, fn := range optFns {
fn(unmarshaledError)
}
return unmarshaledError
}
func WithQueryCompatibility(queryExceptions map[string]func(protocol.ResponseMetadata, string) error) func(*UnmarshalTypedError) {
return func(typedError *UnmarshalTypedError) {
typedError.queryExceptions = queryExceptions
}
}
@ -50,18 +72,32 @@ func (u *UnmarshalTypedError) UnmarshalError(
code := codeParts[len(codeParts)-1]
msg := jsonErr.Message
queryCodeParts := queryCodeParts(resp, u)
if fn, ok := u.exceptions[code]; ok {
// If exception code is know, use associated constructor to get a value
// If query-compatible exceptions are found and query-error-header is found,
// then use associated constructor to get exception with query error code.
//
// If exception code is known, use associated constructor to get a value
// for the exception that the JSON body can be unmarshaled into.
v := fn(respMeta)
var v error
queryErrFn, queryExceptionsFound := u.queryExceptions[code]
if len(queryCodeParts) == awsQueryErrorPartsCount && queryExceptionsFound {
v = queryErrFn(respMeta, queryCodeParts[0])
} else {
v = fn(respMeta)
}
err := jsonutil.UnmarshalJSONCaseInsensitive(v, body)
if err != nil {
return nil, err
}
return v, nil
}
if len(queryCodeParts) == awsQueryErrorPartsCount && len(u.queryExceptions) > 0 {
code = queryCodeParts[0]
}
// fallback to unmodeled generic exceptions
return awserr.NewRequestFailure(
awserr.New(code, msg, nil),
@ -70,6 +106,16 @@ func (u *UnmarshalTypedError) UnmarshalError(
), nil
}
// A valid header example - "x-amzn-query-error": "<QueryErrorCode>;<ErrorType>"
func queryCodeParts(resp *http.Response, u *UnmarshalTypedError) []string {
queryCodeHeader := resp.Header.Get(awsQueryError)
var queryCodeParts []string
if queryCodeHeader != "" && len(u.queryExceptions) > 0 {
queryCodeParts = strings.Split(queryCodeHeader, ";")
}
return queryCodeParts
}
// UnmarshalErrorHandler is a named request handler for unmarshaling jsonrpc
// protocol request errors
var UnmarshalErrorHandler = request.NamedHandler{

@ -1,22 +0,0 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe

@ -1,22 +0,0 @@
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -1,95 +0,0 @@
[![Build Status](https://travis-ci.org/deckarep/golang-set.svg?branch=master)](https://travis-ci.org/deckarep/golang-set)
[![Go Report Card](https://goreportcard.com/badge/github.com/deckarep/golang-set)](https://goreportcard.com/report/github.com/deckarep/golang-set)
[![GoDoc](https://godoc.org/github.com/deckarep/golang-set?status.svg)](http://godoc.org/github.com/deckarep/golang-set)
## golang-set
The missing set collection for the Go language. Until Go has sets built-in...use this.
Coming from Python one of the things I miss is the superbly wonderful set collection. This is my attempt to mimic the primary features of the set from Python.
You can of course argue that there is no need for a set in Go, otherwise the creators would have added one to the standard library. To those I say simply ignore this repository
and carry-on and to the rest that find this useful please contribute in helping me make it better by:
* Helping to make more idiomatic improvements to the code.
* Helping to increase the performance of it. ~~(So far, no attempt has been made, but since it uses a map internally, I expect it to be mostly performant.)~~
* Helping to make the unit-tests more robust and kick-ass.
* Helping to fill in the [documentation.](http://godoc.org/github.com/deckarep/golang-set)
* Simply offering feedback and suggestions. (Positive, constructive feedback is appreciated.)
I have to give some credit for helping seed the idea with this post on [stackoverflow.](http://programmers.stackexchange.com/questions/177428/sets-data-structure-in-golang)
*Update* - as of 3/9/2014, you can use a compile-time generic version of this package in the [gen](http://clipperhouse.github.io/gen/) framework. This framework allows you to use the golang-set in a completely generic and type-safe way by allowing you to generate a supporting .go file based on your custom types.
## Features (as of 9/22/2014)
* a CartesianProduct() method has been added with unit-tests: [Read more about the cartesian product](http://en.wikipedia.org/wiki/Cartesian_product)
## Features (as of 9/15/2014)
* a PowerSet() method has been added with unit-tests: [Read more about the Power set](http://en.wikipedia.org/wiki/Power_set)
## Features (as of 4/22/2014)
* One common interface to both implementations
* Two set implementations to choose from
* a thread-safe implementation designed for concurrent use
* a non-thread-safe implementation designed for performance
* 75 benchmarks for both implementations
* 35 unit tests for both implementations
* 14 concurrent tests for the thread-safe implementation
Please see the unit test file for additional usage examples. The Python set documentation will also do a better job than I can of explaining how a set typically [works.](http://docs.python.org/2/library/sets.html) Please keep in mind
however that the Python set is a built-in type and supports additional features and syntax that make it awesome.
## Examples but not exhaustive:
```go
requiredClasses := mapset.NewSet()
requiredClasses.Add("Cooking")
requiredClasses.Add("English")
requiredClasses.Add("Math")
requiredClasses.Add("Biology")
scienceSlice := []interface{}{"Biology", "Chemistry"}
scienceClasses := mapset.NewSetFromSlice(scienceSlice)
electiveClasses := mapset.NewSet()
electiveClasses.Add("Welding")
electiveClasses.Add("Music")
electiveClasses.Add("Automotive")
bonusClasses := mapset.NewSet()
bonusClasses.Add("Go Programming")
bonusClasses.Add("Python Programming")
//Show me all the available classes I can take
allClasses := requiredClasses.Union(scienceClasses).Union(electiveClasses).Union(bonusClasses)
fmt.Println(allClasses) //Set{Cooking, English, Math, Chemistry, Welding, Biology, Music, Automotive, Go Programming, Python Programming}
//Is cooking considered a science class?
fmt.Println(scienceClasses.Contains("Cooking")) //false
//Show me all classes that are not science classes, since I hate science.
fmt.Println(allClasses.Difference(scienceClasses)) //Set{Music, Automotive, Go Programming, Python Programming, Cooking, English, Math, Welding}
//Which science classes are also required classes?
fmt.Println(scienceClasses.Intersect(requiredClasses)) //Set{Biology}
//How many bonus classes do you offer?
fmt.Println(bonusClasses.Cardinality()) //2
//Do you have the following classes? Welding, Automotive and English?
fmt.Println(allClasses.IsSuperset(mapset.NewSetFromSlice([]interface{}{"Welding", "Automotive", "English"}))) //true
```
Thanks!
-Ralph
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/deckarep/golang-set/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![Analytics](https://ga-beacon.appspot.com/UA-42584447-2/deckarep/golang-set)](https://github.com/igrigorik/ga-beacon)

@ -1,58 +0,0 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package mapset
// Iterator defines an iterator over a Set, its C channel can be used to range over the Set's
// elements.
type Iterator struct {
C <-chan interface{}
stop chan struct{}
}
// Stop stops the Iterator, no further elements will be received on C, C will be closed.
func (i *Iterator) Stop() {
// Allows for Stop() to be called multiple times
// (close() panics when called on already closed channel)
defer func() {
recover()
}()
close(i.stop)
// Exhaust any remaining elements.
for range i.C {
}
}
// newIterator returns a new Iterator instance together with its item and stop channels.
func newIterator() (*Iterator, chan<- interface{}, <-chan struct{}) {
itemChan := make(chan interface{})
stopChan := make(chan struct{})
return &Iterator{
C: itemChan,
stop: stopChan,
}, itemChan, stopChan
}

@ -1,217 +0,0 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Package mapset implements a simple and generic set collection.
// Items stored within it are unordered and unique. It supports
// typical set operations: membership testing, intersection, union,
// difference, symmetric difference and cloning.
//
// Package mapset provides two implementations of the Set
// interface. The default implementation is safe for concurrent
// access, but a non-thread-safe implementation is also provided for
// programs that can benefit from the slight speed improvement and
// that can enforce mutual exclusion through other means.
package mapset
// Set is the primary interface provided by the mapset package. It
// represents an unordered set of data and a large number of
// operations that can be applied to that set.
type Set interface {
// Adds an element to the set. Returns whether
// the item was added.
Add(i interface{}) bool
// Returns the number of elements in the set.
Cardinality() int
// Removes all elements from the set, leaving
// the empty set.
Clear()
// Returns a clone of the set using the same
// implementation, duplicating all keys.
Clone() Set
// Returns whether the given items
// are all in the set.
Contains(i ...interface{}) bool
// Returns the difference between this set
// and other. The returned set will contain
// all elements of this set that are not also
// elements of other.
//
// Note that the argument to Difference
// must be of the same type as the receiver
// of the method. Otherwise, Difference will
// panic.
Difference(other Set) Set
// Determines if two sets are equal to each
// other. If they have the same cardinality
// and contain the same elements, they are
// considered equal. The order in which
// the elements were added is irrelevant.
//
// Note that the argument to Equal must be
// of the same type as the receiver of the
// method. Otherwise, Equal will panic.
Equal(other Set) bool
// Returns a new set containing only the elements
// that exist only in both sets.
//
// Note that the argument to Intersect
// must be of the same type as the receiver
// of the method. Otherwise, Intersect will
// panic.
Intersect(other Set) Set
// Determines if every element in this set is in
// the other set but the two sets are not equal.
//
// Note that the argument to IsProperSubset
// must be of the same type as the receiver
// of the method. Otherwise, IsProperSubset
// will panic.
IsProperSubset(other Set) bool
// Determines if every element in the other set
// is in this set but the two sets are not
// equal.
//
// Note that the argument to IsSuperset
// must be of the same type as the receiver
// of the method. Otherwise, IsSuperset will
// panic.
IsProperSuperset(other Set) bool
// Determines if every element in this set is in
// the other set.
//
// Note that the argument to IsSubset
// must be of the same type as the receiver
// of the method. Otherwise, IsSubset will
// panic.
IsSubset(other Set) bool
// Determines if every element in the other set
// is in this set.
//
// Note that the argument to IsSuperset
// must be of the same type as the receiver
// of the method. Otherwise, IsSuperset will
// panic.
IsSuperset(other Set) bool
// Iterates over elements and executes the passed func against each element.
// If passed func returns true, stop iteration at the time.
Each(func(interface{}) bool)
// Returns a channel of elements that you can
// range over.
Iter() <-chan interface{}
// Returns an Iterator object that you can
// use to range over the set.
Iterator() *Iterator
// Remove a single element from the set.
Remove(i interface{})
// Provides a convenient string representation
// of the current state of the set.
String() string
// Returns a new set with all elements which are
// in either this set or the other set but not in both.
//
// Note that the argument to SymmetricDifference
// must be of the same type as the receiver
// of the method. Otherwise, SymmetricDifference
// will panic.
SymmetricDifference(other Set) Set
// Returns a new set with all elements in both sets.
//
// Note that the argument to Union must be of the
// same type as the receiver of the method.
// Otherwise, IsSuperset will panic.
Union(other Set) Set
// Pop removes and returns an arbitrary item from the set.
Pop() interface{}
// Returns all subsets of a given set (Power Set).
PowerSet() Set
// Returns the Cartesian Product of two sets.
CartesianProduct(other Set) Set
// Returns the members of the set as a slice.
ToSlice() []interface{}
}
// NewSet creates and returns a reference to an empty set. Operations
// on the resulting set are thread-safe.
func NewSet(s ...interface{}) Set {
set := newThreadSafeSet()
for _, item := range s {
set.Add(item)
}
return &set
}
// NewSetWith creates and returns a new set with the given elements.
// Operations on the resulting set are thread-safe.
func NewSetWith(elts ...interface{}) Set {
return NewSetFromSlice(elts)
}
// NewSetFromSlice creates and returns a reference to a set from an
// existing slice. Operations on the resulting set are thread-safe.
func NewSetFromSlice(s []interface{}) Set {
a := NewSet(s...)
return a
}
// NewThreadUnsafeSet creates and returns a reference to an empty set.
// Operations on the resulting set are not thread-safe.
func NewThreadUnsafeSet() Set {
set := newThreadUnsafeSet()
return &set
}
// NewThreadUnsafeSetFromSlice creates and returns a reference to a
// set from an existing slice. Operations on the resulting set are
// not thread-safe.
func NewThreadUnsafeSetFromSlice(s []interface{}) Set {
a := NewThreadUnsafeSet()
for _, item := range s {
a.Add(item)
}
return a
}

@ -1,283 +0,0 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package mapset
import "sync"
type threadSafeSet struct {
s threadUnsafeSet
sync.RWMutex
}
func newThreadSafeSet() threadSafeSet {
return threadSafeSet{s: newThreadUnsafeSet()}
}
func (set *threadSafeSet) Add(i interface{}) bool {
set.Lock()
ret := set.s.Add(i)
set.Unlock()
return ret
}
func (set *threadSafeSet) Contains(i ...interface{}) bool {
set.RLock()
ret := set.s.Contains(i...)
set.RUnlock()
return ret
}
func (set *threadSafeSet) IsSubset(other Set) bool {
o := other.(*threadSafeSet)
set.RLock()
o.RLock()
ret := set.s.IsSubset(&o.s)
set.RUnlock()
o.RUnlock()
return ret
}
func (set *threadSafeSet) IsProperSubset(other Set) bool {
o := other.(*threadSafeSet)
set.RLock()
defer set.RUnlock()
o.RLock()
defer o.RUnlock()
return set.s.IsProperSubset(&o.s)
}
func (set *threadSafeSet) IsSuperset(other Set) bool {
return other.IsSubset(set)
}
func (set *threadSafeSet) IsProperSuperset(other Set) bool {
return other.IsProperSubset(set)
}
func (set *threadSafeSet) Union(other Set) Set {
o := other.(*threadSafeSet)
set.RLock()
o.RLock()
unsafeUnion := set.s.Union(&o.s).(*threadUnsafeSet)
ret := &threadSafeSet{s: *unsafeUnion}
set.RUnlock()
o.RUnlock()
return ret
}
func (set *threadSafeSet) Intersect(other Set) Set {
o := other.(*threadSafeSet)
set.RLock()
o.RLock()
unsafeIntersection := set.s.Intersect(&o.s).(*threadUnsafeSet)
ret := &threadSafeSet{s: *unsafeIntersection}
set.RUnlock()
o.RUnlock()
return ret
}
func (set *threadSafeSet) Difference(other Set) Set {
o := other.(*threadSafeSet)
set.RLock()
o.RLock()
unsafeDifference := set.s.Difference(&o.s).(*threadUnsafeSet)
ret := &threadSafeSet{s: *unsafeDifference}
set.RUnlock()
o.RUnlock()
return ret
}
func (set *threadSafeSet) SymmetricDifference(other Set) Set {
o := other.(*threadSafeSet)
set.RLock()
o.RLock()
unsafeDifference := set.s.SymmetricDifference(&o.s).(*threadUnsafeSet)
ret := &threadSafeSet{s: *unsafeDifference}
set.RUnlock()
o.RUnlock()
return ret
}
func (set *threadSafeSet) Clear() {
set.Lock()
set.s = newThreadUnsafeSet()
set.Unlock()
}
func (set *threadSafeSet) Remove(i interface{}) {
set.Lock()
delete(set.s, i)
set.Unlock()
}
func (set *threadSafeSet) Cardinality() int {
set.RLock()
defer set.RUnlock()
return len(set.s)
}
func (set *threadSafeSet) Each(cb func(interface{}) bool) {
set.RLock()
for elem := range set.s {
if cb(elem) {
break
}
}
set.RUnlock()
}
func (set *threadSafeSet) Iter() <-chan interface{} {
ch := make(chan interface{})
go func() {
set.RLock()
for elem := range set.s {
ch <- elem
}
close(ch)
set.RUnlock()
}()
return ch
}
func (set *threadSafeSet) Iterator() *Iterator {
iterator, ch, stopCh := newIterator()
go func() {
set.RLock()
L:
for elem := range set.s {
select {
case <-stopCh:
break L
case ch <- elem:
}
}
close(ch)
set.RUnlock()
}()
return iterator
}
func (set *threadSafeSet) Equal(other Set) bool {
o := other.(*threadSafeSet)
set.RLock()
o.RLock()
ret := set.s.Equal(&o.s)
set.RUnlock()
o.RUnlock()
return ret
}
func (set *threadSafeSet) Clone() Set {
set.RLock()
unsafeClone := set.s.Clone().(*threadUnsafeSet)
ret := &threadSafeSet{s: *unsafeClone}
set.RUnlock()
return ret
}
func (set *threadSafeSet) String() string {
set.RLock()
ret := set.s.String()
set.RUnlock()
return ret
}
func (set *threadSafeSet) PowerSet() Set {
set.RLock()
unsafePowerSet := set.s.PowerSet().(*threadUnsafeSet)
set.RUnlock()
ret := &threadSafeSet{s: newThreadUnsafeSet()}
for subset := range unsafePowerSet.Iter() {
unsafeSubset := subset.(*threadUnsafeSet)
ret.Add(&threadSafeSet{s: *unsafeSubset})
}
return ret
}
func (set *threadSafeSet) Pop() interface{} {
set.Lock()
defer set.Unlock()
return set.s.Pop()
}
func (set *threadSafeSet) CartesianProduct(other Set) Set {
o := other.(*threadSafeSet)
set.RLock()
o.RLock()
unsafeCartProduct := set.s.CartesianProduct(&o.s).(*threadUnsafeSet)
ret := &threadSafeSet{s: *unsafeCartProduct}
set.RUnlock()
o.RUnlock()
return ret
}
func (set *threadSafeSet) ToSlice() []interface{} {
keys := make([]interface{}, 0, set.Cardinality())
set.RLock()
for elem := range set.s {
keys = append(keys, elem)
}
set.RUnlock()
return keys
}
func (set *threadSafeSet) MarshalJSON() ([]byte, error) {
set.RLock()
b, err := set.s.MarshalJSON()
set.RUnlock()
return b, err
}
func (set *threadSafeSet) UnmarshalJSON(p []byte) error {
set.RLock()
err := set.s.UnmarshalJSON(p)
set.RUnlock()
return err
}

@ -1,340 +0,0 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package mapset
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"strings"
)
type threadUnsafeSet map[interface{}]struct{}
// An OrderedPair represents a 2-tuple of values.
type OrderedPair struct {
First interface{}
Second interface{}
}
func newThreadUnsafeSet() threadUnsafeSet {
return make(threadUnsafeSet)
}
// Equal says whether two 2-tuples contain the same values in the same order.
func (pair *OrderedPair) Equal(other OrderedPair) bool {
if pair.First == other.First &&
pair.Second == other.Second {
return true
}
return false
}
func (set *threadUnsafeSet) Add(i interface{}) bool {
_, found := (*set)[i]
if found {
return false //False if it existed already
}
(*set)[i] = struct{}{}
return true
}
func (set *threadUnsafeSet) Contains(i ...interface{}) bool {
for _, val := range i {
if _, ok := (*set)[val]; !ok {
return false
}
}
return true
}
func (set *threadUnsafeSet) IsSubset(other Set) bool {
_ = other.(*threadUnsafeSet)
if set.Cardinality() > other.Cardinality() {
return false
}
for elem := range *set {
if !other.Contains(elem) {
return false
}
}
return true
}
func (set *threadUnsafeSet) IsProperSubset(other Set) bool {
return set.IsSubset(other) && !set.Equal(other)
}
func (set *threadUnsafeSet) IsSuperset(other Set) bool {
return other.IsSubset(set)
}
func (set *threadUnsafeSet) IsProperSuperset(other Set) bool {
return set.IsSuperset(other) && !set.Equal(other)
}
func (set *threadUnsafeSet) Union(other Set) Set {
o := other.(*threadUnsafeSet)
unionedSet := newThreadUnsafeSet()
for elem := range *set {
unionedSet.Add(elem)
}
for elem := range *o {
unionedSet.Add(elem)
}
return &unionedSet
}
func (set *threadUnsafeSet) Intersect(other Set) Set {
o := other.(*threadUnsafeSet)
intersection := newThreadUnsafeSet()
// loop over smaller set
if set.Cardinality() < other.Cardinality() {
for elem := range *set {
if other.Contains(elem) {
intersection.Add(elem)
}
}
} else {
for elem := range *o {
if set.Contains(elem) {
intersection.Add(elem)
}
}
}
return &intersection
}
func (set *threadUnsafeSet) Difference(other Set) Set {
_ = other.(*threadUnsafeSet)
difference := newThreadUnsafeSet()
for elem := range *set {
if !other.Contains(elem) {
difference.Add(elem)
}
}
return &difference
}
func (set *threadUnsafeSet) SymmetricDifference(other Set) Set {
_ = other.(*threadUnsafeSet)
aDiff := set.Difference(other)
bDiff := other.Difference(set)
return aDiff.Union(bDiff)
}
func (set *threadUnsafeSet) Clear() {
*set = newThreadUnsafeSet()
}
func (set *threadUnsafeSet) Remove(i interface{}) {
delete(*set, i)
}
func (set *threadUnsafeSet) Cardinality() int {
return len(*set)
}
func (set *threadUnsafeSet) Each(cb func(interface{}) bool) {
for elem := range *set {
if cb(elem) {
break
}
}
}
func (set *threadUnsafeSet) Iter() <-chan interface{} {
ch := make(chan interface{})
go func() {
for elem := range *set {
ch <- elem
}
close(ch)
}()
return ch
}
func (set *threadUnsafeSet) Iterator() *Iterator {
iterator, ch, stopCh := newIterator()
go func() {
L:
for elem := range *set {
select {
case <-stopCh:
break L
case ch <- elem:
}
}
close(ch)
}()
return iterator
}
func (set *threadUnsafeSet) Equal(other Set) bool {
_ = other.(*threadUnsafeSet)
if set.Cardinality() != other.Cardinality() {
return false
}
for elem := range *set {
if !other.Contains(elem) {
return false
}
}
return true
}
func (set *threadUnsafeSet) Clone() Set {
clonedSet := newThreadUnsafeSet()
for elem := range *set {
clonedSet.Add(elem)
}
return &clonedSet
}
func (set *threadUnsafeSet) String() string {
items := make([]string, 0, len(*set))
for elem := range *set {
items = append(items, fmt.Sprintf("%v", elem))
}
return fmt.Sprintf("Set{%s}", strings.Join(items, ", "))
}
// String outputs a 2-tuple in the form "(A, B)".
func (pair OrderedPair) String() string {
return fmt.Sprintf("(%v, %v)", pair.First, pair.Second)
}
func (set *threadUnsafeSet) Pop() interface{} {
for item := range *set {
delete(*set, item)
return item
}
return nil
}
func (set *threadUnsafeSet) PowerSet() Set {
powSet := NewThreadUnsafeSet()
nullset := newThreadUnsafeSet()
powSet.Add(&nullset)
for es := range *set {
u := newThreadUnsafeSet()
j := powSet.Iter()
for er := range j {
p := newThreadUnsafeSet()
if reflect.TypeOf(er).Name() == "" {
k := er.(*threadUnsafeSet)
for ek := range *(k) {
p.Add(ek)
}
} else {
p.Add(er)
}
p.Add(es)
u.Add(&p)
}
powSet = powSet.Union(&u)
}
return powSet
}
func (set *threadUnsafeSet) CartesianProduct(other Set) Set {
o := other.(*threadUnsafeSet)
cartProduct := NewThreadUnsafeSet()
for i := range *set {
for j := range *o {
elem := OrderedPair{First: i, Second: j}
cartProduct.Add(elem)
}
}
return cartProduct
}
func (set *threadUnsafeSet) ToSlice() []interface{} {
keys := make([]interface{}, 0, set.Cardinality())
for elem := range *set {
keys = append(keys, elem)
}
return keys
}
// MarshalJSON creates a JSON array from the set, it marshals all elements
func (set *threadUnsafeSet) MarshalJSON() ([]byte, error) {
items := make([]string, 0, set.Cardinality())
for elem := range *set {
b, err := json.Marshal(elem)
if err != nil {
return nil, err
}
items = append(items, string(b))
}
return []byte(fmt.Sprintf("[%s]", strings.Join(items, ","))), nil
}
// UnmarshalJSON recreates a set from a JSON array, it only decodes
// primitive types. Numbers are decoded as json.Number.
func (set *threadUnsafeSet) UnmarshalJSON(b []byte) error {
var i []interface{}
d := json.NewDecoder(bytes.NewReader(b))
d.UseNumber()
err := d.Decode(&i)
if err != nil {
return err
}
for _, v := range i {
switch t := v.(type) {
case []interface{}, map[string]interface{}:
continue
default:
set.Add(t)
}
}
return nil
}

@ -58,6 +58,7 @@ type Config struct {
DisableComputeChecksums bool
S3ForcePathStyle bool
DomainMode bool
SignerVersion string
}
// Copy will return a shallow copy of the Config object.
@ -77,6 +78,7 @@ func (c Config) Copy() Config {
dst.DisableComputeChecksums = c.DisableComputeChecksums
dst.S3ForcePathStyle = c.S3ForcePathStyle
dst.DomainMode = c.DomainMode
dst.SignerVersion = c.SignerVersion
return dst
}
@ -175,5 +177,10 @@ func (c Config) Merge(newcfg *Config) *Config {
} else {
cfg.DomainMode = c.DomainMode
}
if newcfg.SignerVersion != "" {
cfg.SignerVersion = newcfg.SignerVersion
} else {
cfg.SignerVersion = c.SignerVersion
}
return &cfg
}

@ -5,4 +5,4 @@ package aws
const SDKName = "aws-sdk-go"
// SDKVersion is the version of this SDK
const SDKVersion = "1.1.8"
const SDKVersion = "1.1.9"

@ -0,0 +1,371 @@
// Package v4 implements signing for AWS V4 signer
package v4
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"net/url"
"sort"
"strconv"
"strings"
"time"
"github.com/ks3sdklib/aws-sdk-go/aws/credentials"
"github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest"
"github.com/ks3sdklib/aws-sdk-go/aws"
)
const (
authHeaderPrefix = "AWS4-HMAC-SHA256"
timeFormat = "20060102T150405Z"
shortTimeFormat = "20060102"
)
var ignoredHeaders = map[string]bool{
"Authorization": true,
"Content-Type": true,
"Content-Length": true,
"User-Agent": true,
}
type signer struct {
Request *http.Request
Time time.Time
ExpireTime time.Duration
ServiceName string
Region string
CredValues credentials.Value
Credentials *credentials.Credentials
Query url.Values
Body io.ReadSeeker
Debug uint
Logger io.Writer
isPresign bool
isSignBody bool
formattedTime string
formattedShortTime string
signedHeaders string
canonicalHeaders string
canonicalString string
credentialString string
stringToSign string
signature string
authorization string
}
// Sign requests with signature version 4.
//
// Will sign the requests with the service config's Credentials object
// Signing is skipped if the credentials is the credentials.AnonymousCredentials
// object.
func Sign(req *aws.Request) {
// If the request does not need to be signed ignore the signing of the
// request if the AnonymousCredentials object is used.
if req.Service.Config.Credentials == credentials.AnonymousCredentials {
return
}
region := req.Service.SigningRegion
if region == "" {
region = req.Service.Config.Region
}
name := req.Service.SigningName
if name == "" {
name = req.Service.ServiceName
}
s := signer{
Request: req.HTTPRequest,
Time: req.Time,
ExpireTime: req.ExpireTime,
Query: req.HTTPRequest.URL.Query(),
Body: req.Body,
ServiceName: name,
Region: region,
Credentials: req.Service.Config.Credentials,
Debug: req.Service.Config.LogLevel,
Logger: req.Service.Config.Logger,
}
if req.Service.Config.SignerVersion == "V4_UNSIGNED_PAYLOAD_SIGNER" {
s.isSignBody = false
} else {
s.isSignBody = true
}
req.Error = s.sign()
}
func (v4 *signer) sign() error {
if v4.ExpireTime != 0 {
v4.isPresign = true
}
if v4.isRequestSigned() {
if !v4.Credentials.IsExpired() {
// If the request is already signed, and the credentials have not
// expired yet ignore the signing request.
return nil
}
// The credentials have expired for this request. The current signing
// is invalid, and needs to be request because the request will fail.
if v4.isPresign {
v4.removePresign()
// Update the request's query string to ensure the values stays in
// sync in the case retrieving the new credentials fails.
v4.Request.URL.RawQuery = v4.Query.Encode()
}
}
var err error
v4.CredValues, err = v4.Credentials.Get()
if err != nil {
return err
}
if v4.isPresign {
v4.Query.Set("X-Amz-Algorithm", authHeaderPrefix)
if v4.CredValues.SessionToken != "" {
v4.Query.Set("X-Amz-Security-Token", v4.CredValues.SessionToken)
} else {
v4.Query.Del("X-Amz-Security-Token")
}
} else if v4.CredValues.SessionToken != "" {
v4.Request.Header.Set("X-Amz-Security-Token", v4.CredValues.SessionToken)
}
v4.build()
if v4.Debug > 0 {
v4.logSigningInfo()
}
return nil
}
func (v4 *signer) logSigningInfo() {
out := v4.Logger
fmt.Fprintf(out, "---[ CANONICAL STRING ]-----------------------------\n")
fmt.Fprintln(out, v4.canonicalString)
fmt.Fprintf(out, "---[ STRING TO SIGN ]--------------------------------\n")
fmt.Fprintln(out, v4.stringToSign)
if v4.isPresign {
fmt.Fprintf(out, "---[ SIGNED URL ]--------------------------------\n")
fmt.Fprintln(out, v4.Request.URL)
}
fmt.Fprintf(out, "-----------------------------------------------------\n")
}
func (v4 *signer) build() {
v4.buildTime() // no depends
v4.buildCredentialString() // no depends
if v4.isPresign {
v4.buildQuery() // no depends
}
v4.buildCanonicalHeaders() // depends on cred string
v4.buildCanonicalString() // depends on canon headers / signed headers
v4.buildStringToSign() // depends on canon string
v4.buildSignature() // depends on string to sign
if v4.isPresign {
v4.Request.URL.RawQuery += "&X-Amz-Signature=" + v4.signature
} else {
parts := []string{
authHeaderPrefix + " Credential=" + v4.CredValues.AccessKeyID + "/" + v4.credentialString,
"SignedHeaders=" + v4.signedHeaders,
"Signature=" + v4.signature,
}
v4.Request.Header.Set("Authorization", strings.Join(parts, ", "))
}
}
func (v4 *signer) buildTime() {
v4.formattedTime = v4.Time.UTC().Format(timeFormat)
v4.formattedShortTime = v4.Time.UTC().Format(shortTimeFormat)
if v4.isPresign {
duration := int64(v4.ExpireTime / time.Second)
v4.Query.Set("X-Amz-Date", v4.formattedTime)
v4.Query.Set("X-Amz-Expires", strconv.FormatInt(duration, 10))
} else {
v4.Request.Header.Set("X-Amz-Date", v4.formattedTime)
}
}
func (v4 *signer) buildCredentialString() {
v4.credentialString = strings.Join([]string{
v4.formattedShortTime,
v4.Region,
v4.ServiceName,
"aws4_request",
}, "/")
if v4.isPresign {
v4.Query.Set("X-Amz-Credential", v4.CredValues.AccessKeyID+"/"+v4.credentialString)
}
}
func (v4 *signer) buildQuery() {
for k, h := range v4.Request.Header {
if strings.HasPrefix(http.CanonicalHeaderKey(k), "X-Amz-") {
continue // never hoist x-amz-* headers, they must be signed
}
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // never hoist ignored headers
}
v4.Request.Header.Del(k)
v4.Query.Del(k)
for _, v := range h {
v4.Query.Add(k, v)
}
}
}
func (v4 *signer) buildCanonicalHeaders() {
var headers []string
headers = append(headers, "host")
for k := range v4.Request.Header {
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // ignored header
}
headers = append(headers, strings.ToLower(k))
}
sort.Strings(headers)
v4.signedHeaders = strings.Join(headers, ";")
if v4.isPresign {
v4.Query.Set("X-Amz-SignedHeaders", v4.signedHeaders)
}
headerValues := make([]string, len(headers))
for i, k := range headers {
if k == "host" {
headerValues[i] = "host:" + v4.Request.URL.Host
} else {
headerValues[i] = k + ":" +
strings.Join(v4.Request.Header[http.CanonicalHeaderKey(k)], ",")
}
}
v4.canonicalHeaders = strings.Join(headerValues, "\n")
}
func (v4 *signer) buildCanonicalString() {
v4.Request.URL.RawQuery = strings.Replace(v4.Query.Encode(), "+", "%20", -1)
uri := v4.Request.URL.Opaque
if uri != "" {
uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/")
} else {
uri = v4.Request.URL.Path
}
if uri == "" {
uri = "/"
}
if v4.ServiceName != "s3" {
uri = rest.EscapePath(uri, false)
}
v4.canonicalString = strings.Join([]string{
v4.Request.Method,
uri,
v4.Request.URL.RawQuery,
v4.canonicalHeaders + "\n",
v4.signedHeaders,
v4.bodyDigest(),
}, "\n")
}
func (v4 *signer) buildStringToSign() {
v4.stringToSign = strings.Join([]string{
authHeaderPrefix,
v4.formattedTime,
v4.credentialString,
hex.EncodeToString(makeSha256([]byte(v4.canonicalString))),
}, "\n")
}
func (v4 *signer) buildSignature() {
secret := v4.CredValues.SecretAccessKey
date := makeHmac([]byte("AWS4"+secret), []byte(v4.formattedShortTime))
region := makeHmac(date, []byte(v4.Region))
service := makeHmac(region, []byte(v4.ServiceName))
credentials := makeHmac(service, []byte("aws4_request"))
signature := makeHmac(credentials, []byte(v4.stringToSign))
v4.signature = hex.EncodeToString(signature)
}
func (v4 *signer) bodyDigest() string {
hash := v4.Request.Header.Get("X-Amz-Content-Sha256")
if hash == "" {
if v4.isPresign && v4.ServiceName == "s3" {
hash = "UNSIGNED-PAYLOAD"
} else {
if v4.isSignBody {
if v4.Body == nil {
hash = hex.EncodeToString(makeSha256([]byte{}))
} else {
hash = hex.EncodeToString(makeSha256Reader(v4.Body))
}
} else {
hash = "UNSIGNED-PAYLOAD"
}
}
v4.Request.Header.Add("X-Amz-Content-Sha256", hash)
}
return hash
}
// isRequestSigned returns if the request is currently signed or presigned
func (v4 *signer) isRequestSigned() bool {
if v4.isPresign && v4.Query.Get("X-Amz-Signature") != "" {
return true
}
if v4.Request.Header.Get("Authorization") != "" {
return true
}
return false
}
// unsign removes signing flags for both signed and presigned requests.
func (v4 *signer) removePresign() {
v4.Query.Del("X-Amz-Algorithm")
v4.Query.Del("X-Amz-Signature")
v4.Query.Del("X-Amz-Security-Token")
v4.Query.Del("X-Amz-Date")
v4.Query.Del("X-Amz-Expires")
v4.Query.Del("X-Amz-Credential")
v4.Query.Del("X-Amz-SignedHeaders")
}
func makeHmac(key []byte, data []byte) []byte {
hash := hmac.New(sha256.New, key)
hash.Write(data)
return hash.Sum(nil)
}
func makeSha256(data []byte) []byte {
hash := sha256.New()
hash.Write(data)
return hash.Sum(nil)
}
func makeSha256Reader(reader io.ReadSeeker) []byte {
hash := sha256.New()
start, _ := reader.Seek(0, 1)
defer reader.Seek(start, 0)
io.Copy(hash, reader)
return hash.Sum(nil)
}

@ -12,7 +12,6 @@ import (
"encoding/xml"
"errors"
"fmt"
mapset "github.com/deckarep/golang-set"
"github.com/ks3sdklib/aws-sdk-go/aws"
"github.com/ks3sdklib/aws-sdk-go/aws/awserr"
"hash"
@ -20,6 +19,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"os"
"sort"
"strings"
"sync"
@ -27,6 +27,7 @@ import (
)
var oprw sync.Mutex
var TempFileSuffix = ".temp" // Temp file suffix
// AbortMultipartUploadRequest generates a request for the AbortMultipartUpload operation.
func (c *S3) AbortMultipartUploadRequest(input *AbortMultipartUploadInput) (req *aws.Request, output *AbortMultipartUploadOutput) {
@ -1189,6 +1190,34 @@ func (c *S3) GetObject(input *GetObjectInput) (*GetObjectOutput, error) {
err := req.Send()
return out, err
}
func (c *S3) GetObjectToFile(bucket, objectKey, filePath, Range string) error {
tempFilePath := filePath + TempFileSuffix
getInput := &GetObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(objectKey),
Range: aws.String(Range),
}
// Calls the API to actually download the object. Returns the result instance.
req, err := c.GetObject(getInput)
if err != nil {
return err
}
// If the local file does not exist, create a new one. If it exists, overwrite it.
fd, err := os.OpenFile(tempFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, os.FileMode(0664))
if err != nil {
return err
}
// Copy the data to the local file path.
_, err = io.Copy(fd, req.Body)
fd.Close()
if err != nil {
return err
}
return os.Rename(tempFilePath, filePath)
}
func (c *S3) GetObjectPresignedUrl(input *GetObjectInput, expires time.Duration) (*url.URL, error) {
req, _ := c.GetObjectRequest(input)
req.ExpireTime = expires
@ -2114,6 +2143,13 @@ func (c *S3) PutObject(input *PutObjectInput) (*PutObjectOutput, error) {
return out, err
}
//func (c *S3) PutObjectMD5Check(input *PutObjectInput) (*PutObjectOutput, error) {
// req, out := c.PutObjectRequest(input)
// req.Handlers.Build.PushBack(contentMD5)
// err := req.Send()
// return out, err
//}
func (c *S3) PutObjectPresignedUrl(input *PutObjectInput, expires time.Duration) (*url.URL, error) {
req, _ := c.PutObjectRequest(input)
req.ExpireTime = expires
@ -2310,6 +2346,8 @@ type AbortMultipartUploadOutput struct {
RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
metadataAbortMultipartUploadOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataAbortMultipartUploadOutput struct {
@ -2479,6 +2517,8 @@ type CompleteMultipartUploadOutput struct {
VersionID *string `location:"header" locationName:"x-amz-version-id" type:"string"`
metadataCompleteMultipartUploadOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataCompleteMultipartUploadOutput struct {
@ -2692,6 +2732,8 @@ type CopyObjectOutput struct {
ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
metadataCopyObjectOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataCopyObjectOutput struct {
@ -2777,6 +2819,8 @@ type CreateBucketOutput struct {
Location *string `location:"header" locationName:"Location" type:"string"`
metadataCreateBucketOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataCreateBucketOutput struct {
@ -2942,6 +2986,8 @@ type metadataDeleteBucketCORSInput struct {
type DeleteBucketCORSOutput struct {
metadataDeleteBucketCORSOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteBucketCORSOutput struct {
@ -2974,6 +3020,8 @@ type metadataDeleteBucketLifecycleInput struct {
type DeleteBucketLifecycleOutput struct {
metadataDeleteBucketLifecycleOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteBucketLifecycleOutput struct {
@ -2982,6 +3030,8 @@ type metadataDeleteBucketLifecycleOutput struct {
type DeleteBucketOutput struct {
metadataDeleteBucketOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteBucketOutput struct {
@ -3002,6 +3052,8 @@ type metadataDeleteBucketPolicyInput struct {
type DeleteBucketPolicyOutput struct {
metadataDeleteBucketPolicyOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteBucketPolicyOutput struct {
@ -3022,6 +3074,8 @@ type metadataDeleteBucketReplicationInput struct {
type DeleteBucketReplicationOutput struct {
metadataDeleteBucketReplicationOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteBucketReplicationOutput struct {
@ -3042,6 +3096,8 @@ type metadataDeleteBucketTaggingInput struct {
type DeleteBucketTaggingOutput struct {
metadataDeleteBucketTaggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteBucketTaggingOutput struct {
@ -3062,6 +3118,8 @@ type metadataDeleteBucketWebsiteInput struct {
type DeleteBucketWebsiteOutput struct {
metadataDeleteBucketWebsiteOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteBucketWebsiteOutput struct {
@ -3138,6 +3196,8 @@ type DeleteObjectOutput struct {
VersionID *string `location:"header" locationName:"x-amz-version-id" type:"string"`
metadataDeleteObjectOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteObjectOutput struct {
@ -3182,6 +3242,8 @@ type DeleteObjectsOutput struct {
RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
metadataDeleteObjectsOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteObjectsOutput struct {
@ -3262,6 +3324,8 @@ type GetBucketACLOutput struct {
Owner *Owner `type:"structure"`
metadataGetBucketACLOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketACLOutput struct {
@ -3284,6 +3348,8 @@ type GetBucketCORSOutput struct {
CORSRules []*CORSRule `locationName:"CORSRule" type:"list" flattened:"true"`
metadataGetBucketCORSOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketCORSOutput struct {
@ -3321,6 +3387,8 @@ type GetBucketLifecycleOutput struct {
Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true"`
metadataGetBucketLifecycleOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketLifecycleOutput struct {
@ -3343,6 +3411,8 @@ type GetBucketLocationOutput struct {
LocationConstraint *string `type:"string"`
metadataGetBucketLocationOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketLocationOutput struct {
@ -3365,6 +3435,8 @@ type GetBucketLoggingOutput struct {
LoggingEnabled *LoggingEnabled `type:"structure"`
metadataGetBucketLoggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketLoggingOutput struct {
@ -3399,6 +3471,8 @@ type GetBucketPolicyOutput struct {
Policy *string `type:"string"`
metadataGetBucketPolicyOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketPolicyOutput struct {
@ -3423,6 +3497,8 @@ type GetBucketReplicationOutput struct {
ReplicationConfiguration *ReplicationConfiguration `type:"structure"`
metadataGetBucketReplicationOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketReplicationOutput struct {
@ -3446,6 +3522,8 @@ type GetBucketRequestPaymentOutput struct {
Payer *string `type:"string"`
metadataGetBucketRequestPaymentOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketRequestPaymentOutput struct {
@ -3468,6 +3546,8 @@ type GetBucketTaggingOutput struct {
TagSet []*Tag `locationNameList:"Tag" type:"list" required:"true"`
metadataGetBucketTaggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketTaggingOutput struct {
@ -3496,6 +3576,8 @@ type GetBucketVersioningOutput struct {
Status *string `type:"string"`
metadataGetBucketVersioningOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketVersioningOutput struct {
@ -3524,6 +3606,8 @@ type GetBucketWebsiteOutput struct {
RoutingRules []*RoutingRule `locationNameList:"RoutingRule" type:"list"`
metadataGetBucketWebsiteOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetBucketWebsiteOutput struct {
@ -3564,6 +3648,8 @@ type GetObjectACLOutput struct {
RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
metadataGetObjectACLOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetObjectACLOutput struct {
@ -3698,9 +3784,6 @@ type GetObjectOutput struct {
// Last modified date of the object
LastModified *time.Time `location:"header" locationName:"Last-Modified" type:"timestamp" timestampFormat:"rfc822"`
// A map of metadata to store with the object in S3.
Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
// This is set to the number of metadata entries not returned in x-amz-meta
// headers. This can happen if you create metadata using an API like SOAP that
// supports more flexible metadata than the REST API. For example, using SOAP,
@ -3744,6 +3827,8 @@ type GetObjectOutput struct {
WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
metadataGetObjectOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetObjectOutput struct {
@ -3778,6 +3863,8 @@ type GetObjectTorrentOutput struct {
RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
metadataGetObjectTorrentOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetObjectTorrentOutput struct {
@ -3834,6 +3921,8 @@ type metadataHeadBucketInput struct {
type HeadBucketOutput struct {
metadataHeadBucketOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataHeadBucketOutput struct {
@ -3942,9 +4031,6 @@ type HeadObjectOutput struct {
// Last modified date of the object
LastModified *time.Time `location:"header" locationName:"Last-Modified" type:"timestamp" timestampFormat:"rfc822"`
// A map of metadata to store with the object in S3.
Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
// This is set to the number of metadata entries not returned in x-amz-meta
// headers. This can happen if you create metadata using an API like SOAP that
// supports more flexible metadata than the REST API. For example, using SOAP,
@ -3988,6 +4074,8 @@ type HeadObjectOutput struct {
WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"`
metadataHeadObjectOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataHeadObjectOutput struct {
@ -4119,6 +4207,8 @@ type ListBucketsOutput struct {
Owner *Owner `type:"structure"`
metadataListBucketsOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataListBucketsOutput struct {
@ -4208,6 +4298,8 @@ type ListMultipartUploadsOutput struct {
Uploads []*MultipartUpload `locationName:"Upload" type:"list" flattened:"true"`
metadataListMultipartUploadsOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataListMultipartUploadsOutput struct {
@ -4287,6 +4379,8 @@ type ListObjectVersionsOutput struct {
Versions []*ObjectVersion `locationName:"Version" type:"list" flattened:"true"`
metadataListObjectVersionsOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataListObjectVersionsOutput struct {
@ -4358,6 +4452,8 @@ type ListObjectsOutput struct {
Prefix *string `type:"string"`
metadataListObjectsOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataListObjectsOutput struct {
@ -4433,6 +4529,8 @@ type ListPartsOutput struct {
UploadID *string `locationName:"UploadId" type:"string"`
metadataListPartsOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataListPartsOutput struct {
@ -4692,6 +4790,8 @@ type metadataPutBucketACLInput struct {
type PutBucketACLOutput struct {
metadataPutBucketACLOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketACLOutput struct {
@ -4714,6 +4814,8 @@ type metadataPutBucketCORSInput struct {
type PutBucketCORSOutput struct {
metadataPutBucketCORSOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketCORSOutput struct {
@ -4736,6 +4838,8 @@ type metadataPutBucketLifecycleInput struct {
type PutBucketLifecycleOutput struct {
metadataPutBucketLifecycleOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketLifecycleOutput struct {
@ -4758,6 +4862,8 @@ type metadataPutBucketLoggingInput struct {
type PutBucketLoggingOutput struct {
metadataPutBucketLoggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketLoggingOutput struct {
@ -4782,6 +4888,8 @@ type metadataPutBucketNotificationConfigurationInput struct {
type PutBucketNotificationConfigurationOutput struct {
metadataPutBucketNotificationConfigurationOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketNotificationConfigurationOutput struct {
@ -4804,6 +4912,8 @@ type metadataPutBucketNotificationInput struct {
type PutBucketNotificationOutput struct {
metadataPutBucketNotificationOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketNotificationOutput struct {
@ -4827,6 +4937,8 @@ type metadataPutBucketPolicyInput struct {
type PutBucketPolicyOutput struct {
metadataPutBucketPolicyOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketPolicyOutput struct {
@ -4851,6 +4963,8 @@ type metadataPutBucketReplicationInput struct {
type PutBucketReplicationOutput struct {
metadataPutBucketReplicationOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketReplicationOutput struct {
@ -4895,6 +5009,8 @@ type metadataPutBucketTaggingInput struct {
type PutBucketTaggingOutput struct {
metadataPutBucketTaggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketTaggingOutput struct {
@ -4921,6 +5037,8 @@ type metadataPutBucketVersioningInput struct {
type PutBucketVersioningOutput struct {
metadataPutBucketVersioningOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketVersioningOutput struct {
@ -4943,6 +5061,8 @@ type metadataPutBucketWebsiteInput struct {
type PutBucketWebsiteOutput struct {
metadataPutBucketWebsiteOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutBucketWebsiteOutput struct {
@ -4996,6 +5116,8 @@ type PutObjectACLOutput struct {
RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string"`
metadataPutObjectACLOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutObjectACLOutput struct {
@ -5240,6 +5362,8 @@ type PutObjectOutput struct {
NewFileName *string `location:"header" locationName:"newfilename" type:"string"`
metadataPutObjectOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutObjectOutput struct {
@ -5408,10 +5532,8 @@ type metadataRestoreObjectInput struct {
type RestoreObjectOutput struct {
Ks3WebServiceResponse
}
type metadataRestoreObjectOutput struct {
SDKShapeTraits bool `type:"structure"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type RestoreRequest struct {
@ -5651,6 +5773,8 @@ type UploadPartCopyOutput struct {
ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
metadataUploadPartCopyOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataUploadPartCopyOutput struct {
@ -5733,6 +5857,8 @@ type UploadPartOutput struct {
ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
metadataUploadPartOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataUploadPartOutput struct {
@ -5871,14 +5997,14 @@ const (
func GetAcl(resp GetObjectACLOutput) CannedAccessControlType {
allUsersPermissions := mapset.NewSet()
allUsersPermissions := map[string]*string{}
for _, value := range resp.Grants {
if value.Grantee.URI != nil && *value.Grantee.URI == AllUsersUri {
allUsersPermissions.Add(value.Permission)
allUsersPermissions[*value.Permission] = value.Permission
}
}
read := allUsersPermissions.Contains("READ")
write := allUsersPermissions.Contains("WRITE")
_, read := allUsersPermissions["READ"]
_, write := allUsersPermissions["WRITE"]
if read && write {
return PublicReadWrite
} else if read {
@ -5980,6 +6106,8 @@ type metadataDeleteObjectTaggingInput struct {
type DeleteObjectTaggingOutput struct {
metadataDeleteObjectTaggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataDeleteObjectTaggingOutput struct {
@ -6042,6 +6170,8 @@ type GetObjectTaggingOutput struct {
Tagging *Tagging `locationName:"Tagging" type:"structure"`
metadataGetObjectTaggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataGetObjectTaggingOutput struct {
@ -6103,6 +6233,8 @@ type metadataPutObjectTaggingInput struct {
type PutObjectTaggingOutput struct {
metadataPutObjectTaggingOutput `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type metadataPutObjectTaggingOutput struct {
@ -6347,7 +6479,7 @@ func (c *S3) PutBucketMirror(input *PutBucketMirrorInput) (*PutBucketMirrorOutpu
url := c.Endpoint + resource
data, err := json.Marshal(input.BucketMirror)
if err != nil {
panic(errors.New("解析失败" + string(data)))
return nil, errors.New("error" + string(data))
}
request, _ := http.NewRequest("PUT", url, bytes.NewReader(data))
request.Header.Set(HTTPHeaderContentType, "application/json")
@ -6387,6 +6519,8 @@ type PutBucketMirrorInput struct {
type PutBucketMirrorOutput struct {
Ks3WebServiceResponse `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
type GetBucketMirrorInput struct {
@ -6396,6 +6530,8 @@ type GetBucketMirrorInput struct {
type GetBucketMirrorOutput struct {
Ks3WebServiceResponse `json:"-" xml:"-"`
BucketMirror *BucketMirror `locationName:"Mirror" type:"structure"`
Metadata map[string]*string `location:"headers" type:"map"`
}
func (c *S3) GetBucketMirror(input *GetBucketMirrorInput) (*GetBucketMirrorOutput, error) {
@ -6446,6 +6582,8 @@ type DeleteBucketMirrorInput struct {
}
type DeleteBucketMirrorOutput struct {
Ks3WebServiceResponse `json:"-" xml:"-"`
Metadata map[string]*string `location:"headers" type:"map"`
}
func (c *S3) DeleteBucketMirror(input *DeleteBucketMirrorInput) (*DeleteBucketMirrorOutput, error) {

@ -5,7 +5,8 @@ package s3
import (
"github.com/ks3sdklib/aws-sdk-go/aws"
"github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml"
"github.com/ks3sdklib/aws-sdk-go/internal/signer/v2"
v2 "github.com/ks3sdklib/aws-sdk-go/internal/signer/v2"
v4 "github.com/ks3sdklib/aws-sdk-go/internal/signer/v4"
"strings"
)
@ -30,7 +31,14 @@ func New(config *aws.Config) *S3 {
service.Initialize()
// Handlers
service.Handlers.Sign.PushBack(v2.Sign)
if config.SignerVersion == "V4" {
service.Handlers.Sign.PushBack(v4.Sign)
} else if config.SignerVersion == "V4_UNSIGNED_PAYLOAD_SIGNER" {
service.Handlers.Sign.PushBack(v4.Sign)
} else {
service.Handlers.Sign.PushBack(v2.Sign)
}
service.Handlers.Build.PushBack(restxml.Build)
//service.Handlers.Build.PushBack(aws.ContentTypeHandler)
service.Handlers.Unmarshal.PushBack(restxml.Unmarshal)

@ -1,5 +1,5 @@
//go:build (darwin || freebsd || openbsd || netbsd || dragonfly) && !appengine
// +build darwin freebsd openbsd netbsd dragonfly
//go:build (darwin || freebsd || openbsd || netbsd || dragonfly || hurd) && !appengine
// +build darwin freebsd openbsd netbsd dragonfly hurd
// +build !appengine
package isatty

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
## v0.3.1 — 2022-12-28
### Fixed
- Sometimes the nonce was not set on the SASL state machine, resulting in
authentication failing
## v0.3.0 — 2022-08-15
### Added

@ -50,7 +50,7 @@ func NewClient(m Mechanism, opts ...Option) *Negotiator {
lname := m.Name
if lname == rname && strings.HasSuffix(lname, "-PLUS") {
machine.state |= RemoteCB
return machine
break
}
}
if len(machine.nonce) == 0 {
@ -76,7 +76,7 @@ func NewServer(m Mechanism, permissions func(*Negotiator) bool, opts ...Option)
lname := m.Name
if lname == rname && strings.HasSuffix(lname, "-PLUS") {
machine.state |= RemoteCB
return machine
break
}
}
if len(machine.nonce) == 0 {

@ -256,7 +256,7 @@ func scramClientNext(name string, fn func() hash.Hash, m *Negotiator, challenge
}
clientSignature := h.Sum(nil)
clientProof := make([]byte, len(clientKey))
xorBytes(clientProof, clientKey, clientSignature)
goXORBytes(clientProof, clientKey, clientSignature)
encodedClientProof := make([]byte, base64.StdEncoding.EncodedLen(len(clientProof)))
base64.StdEncoding.Encode(encodedClientProof, clientProof)

@ -0,0 +1,26 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !go1.20
package sasl
// TODO: remove all the specialized XOR code and use "crypto/subtle".XORBytes
// when Go v1.21 comes out. For more information see:
// https://mellium.im/issue/338
func goXORBytes(dst, x, y []byte) int {
n := len(x)
if len(y) < n {
n = len(y)
}
if n == 0 {
return 0
}
if n > len(dst) {
panic("subtle.XORBytes: dst too short")
}
xorBytes(&dst[0], &x[0], &y[0], n) // arch-specific
return n
}

@ -2,26 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sasl
// xorBytes xors the bytes in a and b. The destination should have enough
// space, otherwise xorBytes will panic. Returns the number of bytes xor'd.
func xorBytes(dst, a, b []byte) int {
n := len(a)
if len(b) < n {
n = len(b)
}
if n == 0 {
return 0
}
_ = dst[n-1]
xorBytesSSE2(&dst[0], &a[0], &b[0], n) // amd64 must have SSE2
return n
}
//go:build !purego
func xorWords(dst, a, b []byte) {
xorBytes(dst, a, b)
}
package sasl
//go:noescape
func xorBytesSSE2(dst, a, b *byte, n int)
func xorBytes(dst, a, b *byte, n int)

@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !purego
#include "textflag.h"
// func xorBytesSSE2(dst, a, b *byte, n int)
TEXT ·xorBytesSSE2(SB), NOSPLIT, $0
// func xorBytes(dst, a, b *byte, n int)
TEXT ·xorBytes(SB), NOSPLIT, $0
MOVQ dst+0(FP), BX
MOVQ a+8(FP), SI
MOVQ b+16(FP), CX

@ -2,28 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sasl
// xorBytes xors the bytes in a and b. The destination should have enough
// space, otherwise xorBytes will panic. Returns the number of bytes xor'd.
func xorBytes(dst, a, b []byte) int {
n := len(a)
if len(b) < n {
n = len(b)
}
if n == 0 {
return 0
}
// make sure dst has enough space
_ = dst[n-1]
//go:build !purego
xorBytesARM64(&dst[0], &a[0], &b[0], n)
return n
}
func xorWords(dst, a, b []byte) {
xorBytes(dst, a, b)
}
package sasl
//go:noescape
func xorBytesARM64(dst, a, b *byte, n int)
func xorBytes(dst, a, b *byte, n int)

@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !purego
#include "textflag.h"
// func xorBytesARM64(dst, a, b *byte, n int)
TEXT ·xorBytesARM64(SB), NOSPLIT|NOFRAME, $0
// func xorBytes(dst, a, b *byte, n int)
TEXT ·xorBytes(SB), NOSPLIT|NOFRAME, $0
MOVD dst+0(FP), R0
MOVD a+8(FP), R1
MOVD b+16(FP), R2

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !amd64 && !ppc64 && !ppc64le && !arm64
//go:build (!amd64 && !arm64 && !ppc64 && !ppc64le) || purego
package sasl
@ -11,81 +11,48 @@ import (
"unsafe"
)
// xorBytes xors the bytes in a and b. The destination should have enough
// space, otherwise xorBytes will panic. Returns the number of bytes xor'd.
func xorBytes(dst, a, b []byte) int {
n := len(a)
if len(b) < n {
n = len(b)
}
if n == 0 {
return 0
}
switch {
case supportsUnaligned:
fastXORBytes(dst, a, b, n)
default:
// TODO(hanwen): if (dst, a, b) have common alignment
// we could still try fastXORBytes. It is not clear
// how often this happens, and it's only worth it if
// the block encryption itself is hardware
// accelerated.
safeXORBytes(dst, a, b, n)
}
return n
}
const wordSize = unsafe.Sizeof(uintptr(0))
const wordSize = int(unsafe.Sizeof(uintptr(0)))
const supportsUnaligned = runtime.GOARCH == "386" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" || runtime.GOARCH == "s390x"
const supportsUnaligned = runtime.GOARCH == "386" ||
runtime.GOARCH == "amd64" ||
runtime.GOARCH == "ppc64" ||
runtime.GOARCH == "ppc64le" ||
runtime.GOARCH == "s390x"
// fastXORBytes xors in bulk. It only works on architectures that
// support unaligned read/writes.
// n needs to be smaller or equal than the length of a and b.
func fastXORBytes(dst, a, b []byte, n int) {
// Assert dst has enough space
_ = dst[n-1]
func xorBytes(dstb, xb, yb *byte, n int) {
// xorBytes assembly is written using pointers and n. Back to slices.
dst := unsafe.Slice(dstb, n)
x := unsafe.Slice(xb, n)
y := unsafe.Slice(yb, n)
w := n / wordSize
if w > 0 {
dw := *(*[]uintptr)(unsafe.Pointer(&dst))
aw := *(*[]uintptr)(unsafe.Pointer(&a))
bw := *(*[]uintptr)(unsafe.Pointer(&b))
for i := 0; i < w; i++ {
dw[i] = aw[i] ^ bw[i]
if supportsUnaligned || aligned(dstb, xb, yb) {
xorLoop(words(dst), words(x), words(y))
if uintptr(n)%wordSize == 0 {
return
}
done := n &^ int(wordSize-1)
dst = dst[done:]
x = x[done:]
y = y[done:]
}
for i := (n - n%wordSize); i < n; i++ {
dst[i] = a[i] ^ b[i]
}
xorLoop(dst, x, y)
}
// n needs to be smaller or equal than the length of a and b.
func safeXORBytes(dst, a, b []byte, n int) {
for i := 0; i < n; i++ {
dst[i] = a[i] ^ b[i]
}
// aligned reports whether dst, x, and y are all word-aligned pointers.
func aligned(dst, x, y *byte) bool {
return (uintptr(unsafe.Pointer(dst))|uintptr(unsafe.Pointer(x))|uintptr(unsafe.Pointer(y)))&(wordSize-1) == 0
}
// fastXORWords XORs multiples of 4 or 8 bytes (depending on architecture.)
// The arguments are assumed to be of equal length.
func fastXORWords(dst, a, b []byte) {
dw := *(*[]uintptr)(unsafe.Pointer(&dst))
aw := *(*[]uintptr)(unsafe.Pointer(&a))
bw := *(*[]uintptr)(unsafe.Pointer(&b))
n := len(b) / wordSize
for i := 0; i < n; i++ {
dw[i] = aw[i] ^ bw[i]
}
// words returns a []uintptr pointing at the same data as x,
// with any trailing partial word removed.
func words(x []byte) []uintptr {
return unsafe.Slice((*uintptr)(unsafe.Pointer(&x[0])), uintptr(len(x))/wordSize)
}
// fastXORWords XORs multiples of 4 or 8 bytes (depending on architecture.)
// The slice arguments a and b are assumed to be of equal length.
func xorWords(dst, a, b []byte) {
if supportsUnaligned {
fastXORWords(dst, a, b)
} else {
safeXORBytes(dst, a, b, len(b))
func xorLoop[T byte | uintptr](dst, x, y []T) {
x = x[:len(dst)] // remove bounds check in loop
y = y[:len(dst)] // remove bounds check in loop
for i := range dst {
dst[i] = x[i] ^ y[i]
}
}

@ -0,0 +1,15 @@
// Copyright 2022 The Mellium Contributors.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.
//go:build go1.20
package sasl
import (
"crypto/subtle"
)
func goXORBytes(dst, x, y []byte) int {
return subtle.XORBytes(dst, x, y)
}

@ -2,28 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ppc64 || ppc64le
//go:build (ppc64 || ppc64le) && !purego
package sasl
// xorBytes xors the bytes in a and b. The destination should have enough
// space, otherwise xorBytes will panic. Returns the number of bytes xor'd.
func xorBytes(dst, a, b []byte) int {
n := len(a)
if len(b) < n {
n = len(b)
}
if n == 0 {
return 0
}
_ = dst[n-1]
xorBytesVSX(&dst[0], &a[0], &b[0], n)
return n
}
func xorWords(dst, a, b []byte) {
xorBytes(dst, a, b)
}
//go:noescape
func xorBytesVSX(dst, a, b *byte, n int)
func xorBytes(dst, a, b *byte, n int)

@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ppc64 || ppc64le
//go:build (ppc64 || ppc64le) && !purego
#include "textflag.h"
// func xorBytesVSX(dst, a, b *byte, n int)
TEXT ·xorBytesVSX(SB), NOSPLIT, $0
// func xorBytes(dst, a, b *byte, n int)
TEXT ·xorBytes(SB), NOSPLIT, $0
MOVD dst+0(FP), R3 // R3 = dst
MOVD a+8(FP), R4 // R4 = a
MOVD b+16(FP), R5 // R5 = b

@ -1,10 +0,0 @@
// Copyright 2022 The Mellium Contributors.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.
package sasl
// Use the xorWords function to avoid the linter complaining about it being
// unused. We import these files from Go and don't want to have to go through
// and remove this function every single time.
var _ = xorWords

10
vendor/modules.txt vendored

@ -10,7 +10,7 @@ github.com/aliyun/aliyun-oss-go-sdk/oss
## explicit; go 1.16
github.com/allegro/bigcache/v3
github.com/allegro/bigcache/v3/queue
# github.com/aws/aws-sdk-go v1.44.168
# github.com/aws/aws-sdk-go v1.44.170
## explicit; go 1.11
github.com/aws/aws-sdk-go/aws
github.com/aws/aws-sdk-go/aws/arn
@ -201,7 +201,6 @@ github.com/clbanning/mxj
github.com/davecgh/go-spew/spew
# github.com/deckarep/golang-set v1.8.0
## explicit; go 1.17
github.com/deckarep/golang-set
# github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
## explicit
github.com/dgryski/go-rendezvous
@ -416,7 +415,7 @@ github.com/klauspost/compress/internal/cpuinfo
github.com/klauspost/compress/internal/snapref
github.com/klauspost/compress/zstd
github.com/klauspost/compress/zstd/internal/xxhash
# github.com/ks3sdklib/aws-sdk-go v1.1.8
# github.com/ks3sdklib/aws-sdk-go v1.2.0
## explicit; go 1.16
github.com/ks3sdklib/aws-sdk-go/aws
github.com/ks3sdklib/aws-sdk-go/aws/awserr
@ -430,6 +429,7 @@ github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest
github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml
github.com/ks3sdklib/aws-sdk-go/internal/protocol/xml/xmlutil
github.com/ks3sdklib/aws-sdk-go/internal/signer/v2
github.com/ks3sdklib/aws-sdk-go/internal/signer/v4
github.com/ks3sdklib/aws-sdk-go/service/s3
# github.com/leodido/go-urn v1.2.1
## explicit; go 1.13
@ -444,7 +444,7 @@ github.com/lib/pq/scram
github.com/mailru/easyjson/buffer
github.com/mailru/easyjson/jlexer
github.com/mailru/easyjson/jwriter
# github.com/mattn/go-isatty v0.0.16
# github.com/mattn/go-isatty v0.0.17
## explicit; go 1.15
github.com/mattn/go-isatty
# github.com/mattn/go-sqlite3 v2.0.3+incompatible
@ -1135,7 +1135,7 @@ k8s.io/utils/net
k8s.io/utils/strings/slices
# lukechampine.com/uint128 v1.2.0
## explicit; go 1.12
# mellium.im/sasl v0.3.0
# mellium.im/sasl v0.3.1
## explicit; go 1.18
mellium.im/sasl
# modernc.org/ccgo/v3 v3.16.8

Loading…
Cancel
Save