GithubHelp home page GithubHelp logo

gotransip's People

Contributors

dionbosschieter avatar fvanmaldegem avatar gaaf avatar jille avatar ldez avatar middagj avatar roaldnefs avatar robingeuze avatar samihsoylu avatar skoef avatar svenwiltink avatar vblinden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gotransip's Issues

Can't install since go.mod (v5.13+)

For Go module libraries with major version >= 2, the major version is required to be part of the module path. See rules here: https://github.com/golang/go/wiki/Modules#semantic-import-versioning

Since v5 is not part of the URL for this library, I can't install it. I can only install versions of the library that predate your usage of go.mod, so the latest version available to me is v5.8.2.

I'm getting API errors (HTTP 500) running domain.setDNSEntries with that version of the library, though, so I'm kinda stuck at this point.

Any ideas?

Reproduction

go.mod

module github.com/korijn/test

go 1.13

require (
	github.com/transip/gotransip v5.18.0
)
$ go mod download
go: finding github.com/transip/gotransip v5.18.0
go: finding github.com/transip/gotransip v5.18.0
go: errors parsing go.mod:
C:\Users\korij\dev\test\go.mod:7: require github.com/transip/gotransip: version "v5.18.0" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v5

Leaving the entry out of go.mod and letting go pull in the library on its own when running go build . installs an outdated version:

github.com/transip/gotransip v5.8.2+incompatible // indirect

Environment

$ go version
go version go1.13.1 windows/amd64

Unable to update IsCustomerLocked from true to false (but works vice versa)

Problem Description

Whenever the IsCustomerLocked boolean on the VPS is set to true, I'm unable to update it back to false. I am however able to set it back to false by sending a plain API request from Postman/cURL or via the frontend.

On the other hand, when IsCustomerLocked is set to false, I am able to update it into true just fine.

Steps to reproduce

  1. Make sure the VPS is in an unlocked state
  2. Lock the VPS using the gotransip API client (this step works)
...
	vps, _ := vpsRepo.GetByName("example-vps1")

	fmt.Printf("Current lock status: %t \n", vps.IsCustomerLocked)

	fmt.Printf("Locking VPS: %s \n", vps.Description)
	vps.IsCustomerLocked = true
	vpsRepo.Update(vps)
...
  1. Verify that the VPS is indeed locked from the frontend (it should be, this part works :))
  2. Now try to unlock it again using the gotransip API client
...
	vps, _ := vpsRepo.GetByName("example-vps1")

	fmt.Printf("Current lock status: %t \n", vps.IsCustomerLocked)

	fmt.Printf("Unlocking VPS: %s \n", vps.Description)
	vps.IsCustomerLocked = false
	vpsRepo.Update(vps)
...

Expected behaviour

The VPS should be back in an unlocked state, where IsCustomerLocked would be false.

Actual behaviour

IsCustomerLocked stays in a true state and is impossible to set back to false from the gotransip API client.

Suggested fix

I'm unsure what exactly is causing this issue, but the fact that a regular cURL command does allow me to set IsCustomerLocked back to false makes me suspect an issue in the implementation of the VPS Repository Update function.

Please allow setting whitelisted and token expiry

(Problem) Description

I'd like to limit the validity of the token to the whitelisted IP's and a shorter amount of time than 1 day.

Suggested fix

Add "Whitelisted" and "Expiry" fields to "ClientConfiguration"

Cannot register domain name

(Problem) Description

Cannot register domain name.

Steps to reproduce

client, _ := gotransip.NewSOAPClient(gotransip.ClientConfig{.....})
err := domain.Register(client, "example.com")

Expected behaviour

Domain name is registred

Actual behaviour

SOAP Fault 204: Exception received from JSON Server: Invalid API signature, signature does not match the request.

Suggested fix

Looking at the code here:

https://github.com/transip/gotransip/blob/master/domain/api.go#L126

It seems a domain name as string is passed as SOAP argument.
Where as the spec seems to indicate a Domain object is required:

https://api.transip.nl/docs/transip.nl/source-class-Transip_DomainService.html#307-318

Granular API controls?

This is a general question related to the API - I'm not sure where general requests could go (other than [email protected]), so I'm posting it here.

When issuing certificates with Let's Encrypt I'm using the TransIP API to e.g. create the needed CNAME and TXT records. But the API has access to my full range of domains and services. E.g. I cannot limit API access to just access a particular domain or even better: just a certain type of actions with a particular domain (e.g. just updating TXT records of example.org).

Such granular control would make it much more useful because I would be able to leave my credentials at different hosts where a possible attack would only expose a very limited set of features.

When looking at the domain actions (which is what I'm using mostly) the current implementation only allows manipulation of the full zone (basically overwriting the whole zone). Although this seems straightforward it gives most users much more control that they would need to have.

Wondering if there is a place to suggest ideas for a possible v6.0 of the API?

Create new release from master

I've written a DNS provider plugin for the lego package to do a DNS-01 challenge for Let's Encrypt. It's currently slated to use the 5.8 release, but unfortunately there are several issues with that release (API errors that vanish when using master which generaters also much clearer errors). I see 5.8 is 13 commits behind master - would it be possible to create a new updated release?

tests fail on 32bit (i686 and armv7hl)

(Problem) Description

I'm packaging this library for Fedora, and I discovered that the tests fail on 32bit architectures. Specifically they failed on i686 and armv7hl.

Steps to reproduce

  1. use a 32bit architecture
  2. cd vps
  3. go test (this may or may not need Fedora's build flags such as -buildmode pie to reproduce, I can't confirm as I don't have this hardware and can only trigger the error in Fedora build)

Expected behaviour

all tests pass

Actual behaviour

Testing: "/builddir/build/BUILD/gotransip-5.8.1/_build/src/github.com/transip/gotransip/vps"
+ GOPATH=/builddir/build/BUILD/gotransip-5.8.1/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '\'''
--- FAIL: TestGetTrafficInformationForVps (0.00s)
    api_test.go:213: 
        	Error Trace:	api_test.go:213
        	Error:      	Not equal: 
        	            	expected: 2483004356
        	            	actual  : 2147483647
        	Test:       	TestGetTrafficInformationForVps
    api_test.go:214: 
        	Error Trace:	api_test.go:214
        	Error:      	Not equal: 
        	            	expected: 4380854877
        	            	actual  : 2147483647
        	Test:       	TestGetTrafficInformationForVps
    api_test.go:215: 
        	Error Trace:	api_test.go:215
        	Error:      	Not equal: 
        	            	expected: 1073741824000
        	            	actual  : 2147483647
        	Test:       	TestGetTrafficInformationForVps
--- FAIL: TestGetPooledTrafficInformation (0.00s)
    api_test.go:231: 
        	Error Trace:	api_test.go:231
        	Error:      	Not equal: 
        	            	expected: 128356924407
        	            	actual  : 2147483647
        	Test:       	TestGetPooledTrafficInformation
    api_test.go:232: 
        	Error Trace:	api_test.go:232
        	Error:      	Not equal: 
        	            	expected: 200639805776
        	            	actual  : 2147483647
        	Test:       	TestGetPooledTrafficInformation
    api_test.go:233: 
        	Error Trace:	api_test.go:233
        	Error:      	Not equal: 
        	            	expected: 16106127360000
        	            	actual  : 2147483647
        	Test:       	TestGetPooledTrafficInformation
FAIL

Please consider lowering "expirationSkew"

(Problem) Description

I'm generating tokens with an expiry of 30 minutes. I noticed that I got multiple tokens created despite the token being in the cache. After investigating, I found the lib assumes time can skew as much as half an hour. This results in every token I just generated to immediately be invalidated.

Steps to reproduce

  1. Generate a token with expiry of 30 minutes
  2. Store token in cache
  3. Retrieve token from cache 1 second later
  4. Try to use that token
  5. A new token is generated

There also seems to be some rate limiting going on, as request fail lots of times with tokens generated in quick succession.

Expected behaviour

To have the token usable for (close to) the configured expiry

Actual behaviour

Non-expired token invalidated immediately

Suggested fix

Lower the expirationSkew to a more sensible value (where I see "sensible" as a reasonable and acceptable expected time skew). Having a more-or-less synchronised time is not exactly rocket-science for a few decades now.

I suggest 1/2 the minimum allowed expiry, if such thing exists. A few second up to 60 sec otherwise. Or make it (package-wide) configurable instead of const.

Update tags to follow semver

(Problem) Description

To be understandable by go module, the tags must follow semver

The tags v5.8, v5.13, v5.14 are not supported.

Steps to reproduce

module github.com/yourusername/project

go 1.12

require (
	github.com/transip/gotransip v5.14
)

Run go mod tidy

Expected behaviour

module github.com/yourusername/project

go 1.12

require (
	github.com/transip/gotransip v5.14.0
)

Actual behaviour

module github.com/yourusername/project

go 1.12

require (
	github.com/transip/gotransip v0.0.0-20190614113603-efb64632cab7
)

Suggested fix

Add tags without remove the previous tags:

  • v5.8.0 on v5.8
  • v5.13.0 on v5.13
  • v5.14.0 on v5.14
git tag v5.8.0 v5.8
git tag v5.13.0 v5.13
git tag v5.14.0 v5.14
git push --tags

Install dependency via dep

(Problem) Description

I'm trying to create a Golang project using golang/dep, and I'm trying to install this project as a dependency. But I get errors, because the code uses github.com/transip/gotransip/v6, but that directory isn't found (obviously).

Steps to reproduce

  1. dep init
  2. dep ensure -add github.com/transip/[email protected]

Expected behaviour

When the dependency has been added, dep will install the dependency in the vendor directory and I can import github.com/transip/gotransip and use it.

Actual behaviour

I get the following errors (and some more, but they're the same as the last 3):

Fetching sources...

Solving failure: No versions of github.com/transip/gotransip met constraints:
	v6.0.3: "github.com/transip/gotransip" imports "github.com/transip/gotransip/v6/authenticator", which contains malformed code: no package exists at "github.com/transip/gotransip/v6/authenticator"
	v6.0.2: Could not introduce github.com/transip/[email protected], as it is not allowed by constraint ^6.0.3 from project github.com/vedicium/dehydrated-transip-dns01-go.
	v6.0.1: Could not introduce github.com/transip/[email protected], as it is not allowed by constraint ^6.0.3 from project github.com/vedicium/dehydrated-transip-dns01-go.
	v6.0.0: Could not introduce github.com/transip/[email protected], as it is not allowed by constraint ^6.0.3 from project github.com/vedicium/dehydrated-transip-dns01-go.

Suggested fix

It looks like it crashes because it can't find github.com/transip/gotransip/v6/authenticator. Probably because it's found in github.com/transip/gotransip/authenticator and not in the v6 directory.

The imports should probably be changed to the root directory (github.com/transip/gotransip. I understand the v6 is used, but isn't it better if you want to use the SOAP API, you just have to install the V5 version?

Cross compilation (Linux to Windows) produces hard to debug runtime bug

(Problem) Description

The terraform provider https://github.com/kevinvalk/terraform-provider-transip is using gotransip and I just added automatic CI building. Because of the golang crossplatform support, I decided to just compile for all different platforms from Linux.

However, the time.LoadLocation method does not work well when cross compiling from Linux to Windows (this is related to #31). Hence, whenever you use the gotransip library that calls int time.LoadLocation, you will get the error: "The system cannot find the path specified.".

Steps to reproduce

  1. Setup a Golang toolchain on Linux
  2. Build from Linux using GOOS=windows GOARCH=amd64 go build
package main

import (
	"log"

	"github.com/transip/gotransip/v6"
	"github.com/transip/gotransip/v6/domain"
)

func main() {
	client, err := gotransip.NewClient(gotransip.DemoClientConfiguration)
	if err != nil {
		panic(err.Error())
	}

	name := "transipdemo.be"
	repository := domain.Repository{Client: client}

	domain, err := repository.GetByDomainName(name)
	if err != nil {
		log.Printf("failed to lookup domain %q: %s", name, err)
	}

	log.Printf("Domain: %v", domain)
}
  1. Run the produced executable on Windows

Note: cross compiling from Windows to Linux seems to work

Expected behaviour

2020/06/12 17:41:34 Domain: {[] ########## 0001-01-01 00:00:00 +0000 UTC  false false false transipdemo.be 2011-04-29 00:00:00 +0200 CEST 2021-04-29 00:00:00 +0200 CEST}

Actual behaviour

2020/06/12 17:41:08 failed to lookup domain "transipdemo.be": The system cannot find the path specified.
2020/06/12 17:41:08 Domain: {[] ########## 0001-01-01 00:00:00 +0000 UTC  false false false transipdemo.be 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC}

Suggested fix

After some googling I found two issues having similar problems

The proper fix would be to transfer times from the back-end in UTC and just keep it in UTC. If the user of the library would like to present times in local time it is up to them to print it for a specific timezone. In that case time.Parse can be used instead of time.ParseInlocation (see https://golang.org/pkg/time/#Parse).

Second best fix would be transfer times from the back-end with timezone information. Then once again time.Parse can be used instead of time.ParseInlocation (see https://golang.org/pkg/time/#Parse).

If that is difficult (because all times are saved in Europe/Amsterdam in the back-end), then I guess the best thing would be to just create a fixed timezone instead of using LoadLocation

loc := time.FixedZone("CEST", 2*60*60)
t, _ := time.ParseInLocation(`"2006-01-02"`, `"2011-04-29"`, loc)
fmt.Println(t)

I created a patch that resolves this using the "worst" of the suggestions: https://gist.github.com/kevinvalk/02a4f78abe7a9705b3404f0992b55df8

Unable to order a Vps without addons

(Problem) Description

Unable to order a Vps without addons.

Steps to reproduce

Running the following code results in a panic: SOAP Fault 204: Exception received from JSON Server: Invalid API signature, signature does not match the request.:

package main

import (
  "github.com/transip/gotransip"
  "github.com/transip/gotransip/vps"
)

func main() {
  // create new TransIP API SOAP client
  c, err := gotransip.NewSOAPClient(gotransip.ClientConfig{
    AccountName: "accountname",
    PrivateKeyPath:  "/path/to/private/key",
  })
  if err != nil {
    panic(err.Error())
  }

  // order a VPS
  productName := "vps-bladevps-x1"
  addons := []string{}
  operatingSystemName := "ubuntu-18.04"
  hostname := "hostname"
  err = vps.OrderVps(c, productName, addons, operatingSystemName, hostname)
  if err != nil {
    panic(err.Error())
  }
}

If a non-existing addon (addons := []string{'nonexisting'}) is specified the client will successfully order the Vps.

Expected behaviour

Should be able to order a Vps without having to add addons.

Actual behaviour

Ordering a Vps without addons results in a panic: SOAP Fault 204: Exception received from JSON Server: Invalid API signature, signature does not match the request..

Suggested fix

n/a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.