diff --git a/LICENSE b/LICENSE index 3f525ca..de8e467 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Nanopack +Copyright (c) 2015-2019 Nanobox, 2019-present The Microbox Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 7844a91..af933cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Portal -[![Build Status](https://travis-ci.org/nanopack/portal.svg)](https://travis-ci.org/nanopack/portal) -[![GoDoc](https://godoc.org/github.com/nanopack/portal?status.svg)](https://godoc.org/github.com/nanopack/portal) +# Portal +[![Build Status](https://github.com/mu-box/portal/actions/workflows/ci.yaml/badge.svg)](https://github.com/mu-box/portal/actions) +[![GoDoc](https://godoc.org/github.com/mu-box/portal?status.svg)](https://godoc.org/github.com/mu-box/portal) Portal is an api-driven, in-kernel layer 2/3 load balancer. ## Status -Complete/Experimental +Complete ## Usage: @@ -71,7 +71,7 @@ Flags: Use "portal [command] --help" for more information about a command. ``` -For usage examples, see [Api](api/README.md) and/or [Cli](commands/README.md) readme +For usage examples, see [API](api/README.md) and/or [CLI](commands/README.md) readme ### As a Server To start portal as a server run: @@ -134,10 +134,10 @@ An optional config file can also be passed on startup: | **Post** /vips | Add new vip | json vip object | json vip object | | **Put** /vips | Reset the list of vips | json array of vip objects | json array of vip objects | -- **service_id** is a formatted combination of service info: type-host-port. (tcp-127_0_0_3-80) -- **server_id** is a formatted combination of server info: host-port. (192_0_0_3-8080) +- **service_id** is a formatted combination of service info: type-host-port. (tcp-127_0_0_3-80) +- **server_id** is a formatted combination of server info: host-port. (192_0_0_3-8080) -For examples, see [the api's readme](api/README.md) +For examples, see [the api's readme](api/README.md) ## Data types: ### Service: @@ -295,9 +295,6 @@ json: Fields: - **msg**: Success message -### Contributing -Portal uses [`govendor`](https://github.com/kardianos/govendor) to manage dependencies. After clone, run `govendor sync` to ensure you have the proper dependencies prior to building. - ## Todo - vip testing - balance vips across cluster @@ -317,4 +314,4 @@ Portal uses [`govendor`](https://github.com/kardianos/govendor) to manage depend - Users can now add vips to portal - Portal now uses the service host for server's hosts that are "127.0.0.1" -[![portal logo](http://nano-assets.gopagoda.io/open-src/nanobox-open-src.png)](http://nanobox.io/open-source) +[![portal logo](http://microbox.rocks/assets/open-src/microbox-open-src.png)](http://microbox.cloud/open-source) diff --git a/Vagrantfile b/Vagrantfile index 55ab29a..1071c6a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : # determine vagrant provider -ENV['VAGRANT_DEFAULT_PROVIDER'] = ENV['NANOBOX_BUILD_VAGRANT_PROVIDER'] || 'virtualbox' +ENV['VAGRANT_DEFAULT_PROVIDER'] = ENV['MICROBOX_BUILD_VAGRANT_PROVIDER'] || 'virtualbox' Vagrant.configure('2') do |config| @@ -18,7 +18,7 @@ Vagrant.configure('2') do |config| v.vmx["numvcpus"] = "1" v.gui = false override.vm.box = "trusty64_vmware" - override.vm.box_url = 'https://github.com/pagodabox/vagrant-packer-templates/releases/download/v0.2.0/trusty64_vmware.box' + override.vm.box_url = 'https://github.com/mu-box/vagrant-packer-templates/releases/download/v0.2.0/trusty64_vmware.box' end config.vm.network "private_network", type: "dhcp" diff --git a/api/README.md b/api/README.md index db82b2e..fde1f43 100644 --- a/api/README.md +++ b/api/README.md @@ -1,5 +1,5 @@ -[![portal logo](http://nano-assets.gopagoda.io/readme-headers/portal.png)](http://nanobox.io/open-source#portal) -[![Build Status](https://travis-ci.org/nanopack/portal.svg)](https://travis-ci.org/nanopack/portal) +[![portal logo](http://microbox.rocks/assets/readme-headers/portal.png)](http://microbox.cloud/open-source#portal) +[![Build Status](https://github.com/mu-box/portal/actions/workflows/ci.yaml/badge.svg)](https://github.com/mu-box/portal/actions) # Portal @@ -216,4 +216,4 @@ $ curl -k -H "X-AUTH-TOKEN:" https://127.0.0.1:8443/vips \ [{"ip":"192.168.0.100","interface":"eth0","alias":"eth0:1"}] ``` -[![portal logo](http://nano-assets.gopagoda.io/open-src/nanobox-open-src.png)](http://nanobox.io/open-source) +[![portal logo](http://microbox.rocks/assets/open-src/microbox-open-src.png)](http://microbox.cloud/open-source) diff --git a/api/api.go b/api/api.go index 9bb097b..96c5af7 100644 --- a/api/api.go +++ b/api/api.go @@ -1,30 +1,30 @@ // api handles the api routes and pertaining funtionality. // -// | Action | Route | Description | Payload | Output | -// |--------|-----------------------------------|---------------------------------------------|---------------------------------------------|-------------------------------| -// | GET | /services | List all services | nil | json array of service objects | -// | POST | /services | Add a service | json service object | json service object | -// | PUT | /services | Reset the list of services | json array of service objects | json array of service objects | -// | PUT | /services/:svc_id | Reset the specified service | nil | json service object | -// | GET | /services/:svc_id | Get information about a service | nil | json service object | -// | DELETE | /services/:svc_id | Delete a service | nil | success message or an error | -// | GET | /services/:svc_id/servers | List all servers on a service | nil | json array of server objects | -// | POST | /services/:svc_id/servers | Add new server to a service | json server object | json server object | -// | PUT | /services/:svc_id/servers | Reset the list of servers on a service | json array of server objects | json array of server objects | -// | GET | /services/:svc_id/servers/:srv_id | Get information about a server on a service | nil | json server object | -// | DELETE | /services/:svc_id/servers/:srv_id | Delete a server from a service | nil | success message or an error | -// | DELETE | /routes | Delete a route | subdomain, domain, and path (json or query) | success message or an error | -// | GET | /routes | List all routes | nil | json array of route objects | -// | POST | /routes | Add new route | json route object | json route object | -// | PUT | /routes | Reset the list of routes | json array of route objects | json array of route objects | -// | DELETE | /certs | Delete a cert | json cert object | success message or an error | -// | GET | /certs | List all certs | nil | json array of cert objects | -// | POST | /certs | Add new cert | json cert object | json cert object | -// | PUT | /certs | Reset the list of certs | json array of cert objects | json array of cert objects | -// | DELETE | /vips | Delete a vip | json vip object | success message or an error | -// | GET | /vips | List all vips | nil | json array of vip objects | -// | POST | /vips | Add new vip | json vip object | json vip object | -// | PUT | /vips | Reset the list of vips | json array of vip objects | json array of vip objects | +// | Action | Route | Description | Payload | Output | +// |--------|-----------------------------------|---------------------------------------------|---------------------------------------------|-------------------------------| +// | GET | /services | List all services | nil | json array of service objects | +// | POST | /services | Add a service | json service object | json service object | +// | PUT | /services | Reset the list of services | json array of service objects | json array of service objects | +// | PUT | /services/:svc_id | Reset the specified service | nil | json service object | +// | GET | /services/:svc_id | Get information about a service | nil | json service object | +// | DELETE | /services/:svc_id | Delete a service | nil | success message or an error | +// | GET | /services/:svc_id/servers | List all servers on a service | nil | json array of server objects | +// | POST | /services/:svc_id/servers | Add new server to a service | json server object | json server object | +// | PUT | /services/:svc_id/servers | Reset the list of servers on a service | json array of server objects | json array of server objects | +// | GET | /services/:svc_id/servers/:srv_id | Get information about a server on a service | nil | json server object | +// | DELETE | /services/:svc_id/servers/:srv_id | Delete a server from a service | nil | success message or an error | +// | DELETE | /routes | Delete a route | subdomain, domain, and path (json or query) | success message or an error | +// | GET | /routes | List all routes | nil | json array of route objects | +// | POST | /routes | Add new route | json route object | json route object | +// | PUT | /routes | Reset the list of routes | json array of route objects | json array of route objects | +// | DELETE | /certs | Delete a cert | json cert object | success message or an error | +// | GET | /certs | List all certs | nil | json array of cert objects | +// | POST | /certs | Add new cert | json cert object | json cert object | +// | PUT | /certs | Reset the list of certs | json array of cert objects | json array of cert objects | +// | DELETE | /vips | Delete a vip | json vip object | success message or an error | +// | GET | /vips | List all vips | nil | json array of vip objects | +// | POST | /vips | Add new vip | json vip object | json vip object | +// | PUT | /vips | Reset the list of vips | json array of vip objects | json array of vip objects | package api // Things this api needs to support @@ -47,13 +47,13 @@ import ( "net/http" "github.com/gorilla/pat" - "github.com/nanobox-io/golang-nanoauth" + microauth "github.com/mu-box/golang-microauth" - "github.com/nanopack/portal/config" + "github.com/mu-box/portal/config" ) var ( - auth nanoauth.Auth + auth microauth.Auth BadJson = errors.New("Bad JSON syntax received in body") BodyReadFail = errors.New("Body Read Failed") NoServerError = errors.New("No Server Found") @@ -80,9 +80,9 @@ func StartApi() error { var cert *tls.Certificate var err error if config.ApiCert == "" { - cert, err = nanoauth.Generate("portal.nanobox.io") + cert, err = microauth.Generate("portal.microbox.cloud") } else { - cert, err = nanoauth.Load(config.ApiCert, config.ApiKey, config.ApiKeyPassword) + cert, err = microauth.Load(config.ApiCert, config.ApiKey, config.ApiKeyPassword) } if err != nil { return err diff --git a/api/api_test.go b/api/api_test.go index b07b0e4..4574bf1 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -14,14 +14,14 @@ import ( "github.com/jcelliott/lumber" - "github.com/nanopack/portal/api" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/database" - "github.com/nanopack/portal/proxymgr" - "github.com/nanopack/portal/vipmgr" + "github.com/mu-box/portal/api" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/database" + "github.com/mu-box/portal/proxymgr" + "github.com/mu-box/portal/vipmgr" ) var ( @@ -73,9 +73,9 @@ func TestMain(m *testing.M) { // Post - /sync postSync // Get - /sync getSync -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVICES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // test get services func TestGetServices(t *testing.T) { body, err := rest("GET", "/services", "") @@ -231,9 +231,9 @@ func TestDeleteService(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVERS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // test get servers func TestGetServers(t *testing.T) { rest("POST", "/services", testService) @@ -349,9 +349,9 @@ func TestDeleteServer(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // ROUTES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // test get routes func TestGetRoutes(t *testing.T) { body, err := rest("GET", "/routes", "") @@ -445,9 +445,9 @@ func TestDeleteRoute(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // CERTS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // test get certs func TestGetCerts(t *testing.T) { body, err := rest("GET", "/certs", "") @@ -535,9 +535,9 @@ func TestDeleteCert(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // PRIVS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // hit api and return response body func rest(method, route, data string) ([]byte, error) { body := bytes.NewBuffer([]byte(data)) diff --git a/api/certificate.go b/api/certificate.go index 0ec1539..eb8a4c6 100644 --- a/api/certificate.go +++ b/api/certificate.go @@ -4,9 +4,9 @@ import ( "net/http" "strings" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/core/common" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/core/common" ) func postCert(rw http.ResponseWriter, req *http.Request) { diff --git a/api/errors.go b/api/errors.go index e3aeef8..c3bcb0f 100644 --- a/api/errors.go +++ b/api/errors.go @@ -3,7 +3,7 @@ package api import ( "net/http" - "github.com/nanobox-io/nanobox-router" + "github.com/mu-box/microbox-router" ) // todo: update router so it uses map[string]string|byte for errors diff --git a/api/route.go b/api/route.go index bf013ac..4b07c7d 100644 --- a/api/route.go +++ b/api/route.go @@ -3,9 +3,9 @@ package api import ( "net/http" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/core/common" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/core/common" ) func postRoute(rw http.ResponseWriter, req *http.Request) { diff --git a/api/server.go b/api/server.go index 85320d1..798dd7c 100644 --- a/api/server.go +++ b/api/server.go @@ -5,10 +5,10 @@ import ( "io/ioutil" "net/http" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/core/common" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/core/common" ) func parseReqServer(req *http.Request) (*core.Server, error) { diff --git a/api/service.go b/api/service.go index 6e66e24..4ee5ad7 100644 --- a/api/service.go +++ b/api/service.go @@ -8,10 +8,10 @@ import ( "strconv" "strings" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/core/common" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/core/common" ) func parseReqService(req *http.Request) (*core.Service, error) { diff --git a/api/vip.go b/api/vip.go index 746fc23..504abe5 100644 --- a/api/vip.go +++ b/api/vip.go @@ -3,9 +3,9 @@ package api import ( "net/http" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/core/common" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/core/common" ) func postVip(rw http.ResponseWriter, req *http.Request) { diff --git a/balance/balance.go b/balance/balance.go index e4e0f1b..55f6ee2 100644 --- a/balance/balance.go +++ b/balance/balance.go @@ -1,3 +1,4 @@ +//go:build linux || darwin // +build linux darwin // balance handles the load balancing portion of portal. @@ -11,8 +12,8 @@ import ( "github.com/coreos/go-iptables/iptables" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) var ( diff --git a/balance/balance_windows.go b/balance/balance_windows.go index 61be69f..c65e970 100644 --- a/balance/balance_windows.go +++ b/balance/balance_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows // balance handles the load balancing portion of portal. @@ -8,8 +9,8 @@ import ( "strconv" "strings" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) var ( diff --git a/balance/lvs.go b/balance/lvs.go index f8b7728..7154c63 100644 --- a/balance/lvs.go +++ b/balance/lvs.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package balance @@ -6,9 +7,9 @@ import ( "fmt" "sync" - "github.com/nanobox-io/golang-lvs" + "github.com/mu-box/golang-lvs" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/core" ) var ( diff --git a/balance/lvs_fake.go b/balance/lvs_fake.go index a45abca..4e19d39 100644 --- a/balance/lvs_fake.go +++ b/balance/lvs_fake.go @@ -1,9 +1,11 @@ +//go:build windows || darwin // +build windows darwin + // this fake lvs enables portal to compile for darwin/windows package balance -import "github.com/nanopack/portal/core" +import "github.com/mu-box/portal/core" type ( Lvs struct { diff --git a/balance/lvs_test.go b/balance/lvs_test.go index dc3441d..fb5194f 100644 --- a/balance/lvs_test.go +++ b/balance/lvs_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package balance_test @@ -12,9 +13,9 @@ import ( "github.com/jcelliott/lumber" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) var ( @@ -34,9 +35,9 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVICES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetService(t *testing.T) { if skip { t.SkipNow() @@ -129,9 +130,9 @@ func TestDeleteService(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVERS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetServer(t *testing.T) { if skip { t.SkipNow() @@ -232,9 +233,9 @@ func TestDeleteServer(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // PRIVS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func toJson(v interface{}) ([]byte, error) { jsonified, err := json.MarshalIndent(v, "", "\t") if err != nil { diff --git a/balance/nginx.go b/balance/nginx.go index 6da5506..9e91577 100644 --- a/balance/nginx.go +++ b/balance/nginx.go @@ -9,8 +9,8 @@ import ( "sync" "text/template" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) var ( diff --git a/balance/nginx_test.go b/balance/nginx_test.go index 382d641..a3ba8bb 100644 --- a/balance/nginx_test.go +++ b/balance/nginx_test.go @@ -7,14 +7,14 @@ import ( "github.com/jcelliott/lumber" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVICES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetServiceNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() @@ -295,9 +295,9 @@ func TestDeleteServerNginx(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // PRIVS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func nginxPrep() bool { nginx, err := exec.Command("which", "nginx").CombinedOutput() // nginx, err := exec.Command("nginx", "-v").CombinedOutput() diff --git a/cluster/cluster.go b/cluster/cluster.go index 6208e49..cef8133 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -1,4 +1,4 @@ -// cluster handles the multi-master clustering of portal. +// cluster handles the multi-primary clustering of portal. package cluster import ( @@ -7,8 +7,8 @@ import ( "fmt" "net/url" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) var ( diff --git a/cluster/none.go b/cluster/none.go index fb10936..e860449 100644 --- a/cluster/none.go +++ b/cluster/none.go @@ -1,9 +1,9 @@ package cluster import ( - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/core/common" - "github.com/nanopack/portal/database" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/core/common" + "github.com/mu-box/portal/database" ) type ( diff --git a/cluster/redis.go b/cluster/redis.go index e2a0e57..d9643bc 100644 --- a/cluster/redis.go +++ b/cluster/redis.go @@ -11,11 +11,11 @@ import ( "github.com/garyburd/redigo/redis" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/core/common" - "github.com/nanopack/portal/database" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/core/common" + "github.com/mu-box/portal/database" ) var ( @@ -649,8 +649,8 @@ func (r *Redis) GetServices() ([]core.Service, error) { members, _ := redis.Strings(conn.Do("SMEMBERS", "members")) if len(members) == 0 { // should only happen on new cluster - // assume i'm ok to be master so don't reset imported services - config.Log.Trace("[cluster] - Assuming OK to be master, using services from my database...") + // assume i'm ok to be primary so don't reset imported services + config.Log.Trace("[cluster] - Assuming OK to be primary, using services from my database...") return common.GetServices() } for i := range members { @@ -750,8 +750,8 @@ func (r *Redis) GetRoutes() ([]core.Route, error) { members, _ := redis.Strings(conn.Do("SMEMBERS", "members")) if len(members) == 0 { // should only happen on new cluster - // assume i'm ok to be master so don't reset imported routes - config.Log.Trace("[cluster] - Assuming OK to be master, using routes from my database...") + // assume i'm ok to be primary so don't reset imported routes + config.Log.Trace("[cluster] - Assuming OK to be primary, using routes from my database...") return common.GetRoutes() } for i := range members { @@ -847,8 +847,8 @@ func (r *Redis) GetCerts() ([]core.CertBundle, error) { members, _ := redis.Strings(conn.Do("SMEMBERS", "members")) if len(members) == 0 { // should only happen on new cluster - // assume i'm ok to be master so don't reset imported certs - config.Log.Trace("[cluster] - Assuming OK to be master, using certs from my database...") + // assume i'm ok to be primary so don't reset imported certs + config.Log.Trace("[cluster] - Assuming OK to be primary, using certs from my database...") return common.GetCerts() } for i := range members { diff --git a/cluster/redis_test.go b/cluster/redis_test.go index cd11832..aea42af 100644 --- a/cluster/redis_test.go +++ b/cluster/redis_test.go @@ -12,13 +12,13 @@ import ( "github.com/garyburd/redigo/redis" "github.com/jcelliott/lumber" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/database" - "github.com/nanopack/portal/proxymgr" - "github.com/nanopack/portal/vipmgr" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/database" + "github.com/mu-box/portal/proxymgr" + "github.com/mu-box/portal/vipmgr" ) var ( @@ -62,9 +62,9 @@ func TestMain(m *testing.M) { os.Exit(rtn) } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVICES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetService(t *testing.T) { if skip { t.SkipNow() @@ -156,9 +156,9 @@ func TestDeleteService(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVERS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetServer(t *testing.T) { if skip { t.SkipNow() @@ -261,9 +261,9 @@ func TestDeleteServer(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // ROUTES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetRoute(t *testing.T) { if skip { t.SkipNow() @@ -338,9 +338,9 @@ func TestDeleteRoute(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // CERTS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetCert(t *testing.T) { if skip { t.SkipNow() @@ -498,9 +498,9 @@ func TestNoneDeleteService(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVERS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestNoneSetServer(t *testing.T) { cluster.SetService(&testService1) if err := cluster.SetServer(testService1.Id, &testServer1); err != nil { @@ -588,9 +588,9 @@ func TestNoneDeleteServer(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // ROUTES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestNoneSetRoute(t *testing.T) { if err := cluster.SetRoute(testRoute); err != nil { t.Errorf("Failed to SET route - %s", err) @@ -653,9 +653,9 @@ func TestNoneDeleteRoute(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // CERTS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestNoneSetCert(t *testing.T) { if err := cluster.SetCert(testCert); err != nil { t.Errorf("Failed to SET cert - %s", err) @@ -718,9 +718,9 @@ func TestNoneDeleteCert(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // PRIVS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func toJson(v interface{}) ([]byte, error) { jsonified, err := json.MarshalIndent(v, "", "\t") if err != nil { diff --git a/commands/README.md b/commands/README.md index b2c87df..e2dcd9c 100644 --- a/commands/README.md +++ b/commands/README.md @@ -1,5 +1,5 @@ -[![portal logo](http://nano-assets.gopagoda.io/readme-headers/portal.png)](http://nanobox.io/open-source#portal) -[![Build Status](https://travis-ci.org/nanopack/portal.svg)](https://travis-ci.org/nanopack/portal) +[![portal logo](http://microbox.rocks/assets/readme-headers/portal.png)](http://microbox.cloud/open-source#portal) +[![Build Status](https://github.com/mu-box/portal/actions/workflows/ci.yaml/badge.svg)](https://github.com/mu-box/portal/actions) # Portal @@ -261,4 +261,4 @@ $ ./portal set-vips -j '[{"ip":"192.168.0.100","interface":"eth0","alias":"eth0: [{"ip":"192.168.0.100","interface":"eth0","alias":"eth0:1"}] ``` -[![portal logo](http://nano-assets.gopagoda.io/open-src/nanobox-open-src.png)](http://nanobox.io/open-source) +[![portal logo](http://microbox.rocks/assets/open-src/microbox-open-src.png)](http://microbox.cloud/open-source) diff --git a/commands/cert.go b/commands/cert.go index 9908450..bb6e2e5 100644 --- a/commands/cert.go +++ b/commands/cert.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/core" ) // add-cert diff --git a/commands/commands.go b/commands/commands.go index 958b493..cfa1af3 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -14,14 +14,14 @@ import ( "github.com/jcelliott/lumber" "github.com/spf13/cobra" - "github.com/nanopack/portal/api" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/database" - "github.com/nanopack/portal/proxymgr" - "github.com/nanopack/portal/vipmgr" + "github.com/mu-box/portal/api" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/database" + "github.com/mu-box/portal/proxymgr" + "github.com/mu-box/portal/vipmgr" ) var ( diff --git a/commands/commands_test.go b/commands/commands_test.go index 434f3b7..2dfaeab 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -12,14 +12,14 @@ import ( "github.com/jcelliott/lumber" - "github.com/nanopack/portal/api" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/cluster" - "github.com/nanopack/portal/commands" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/database" - "github.com/nanopack/portal/proxymgr" - "github.com/nanopack/portal/vipmgr" + "github.com/mu-box/portal/api" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/cluster" + "github.com/mu-box/portal/commands" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/database" + "github.com/mu-box/portal/proxymgr" + "github.com/mu-box/portal/vipmgr" ) type ( @@ -76,9 +76,9 @@ func TestMain(m *testing.M) { os.Exit(rtn) } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVICES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestShowServices(t *testing.T) { Portal.SetArgs(strings.Split("show-services", " ")) @@ -202,9 +202,9 @@ func TestShowServiceId(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // SERVERS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestShowServersHost(t *testing.T) { Portal.SetArgs(strings.Split("show-servers -O 192.168.0.15 -R 80", " ")) @@ -329,9 +329,9 @@ func TestShowServerId(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // ROUTES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestShowRoutes(t *testing.T) { Portal.SetArgs(strings.Split("show-routes", " ")) @@ -385,9 +385,9 @@ func TestSetRoutes(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // CERTS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestShowCerts(t *testing.T) { Portal.SetArgs(strings.Split("show-certs", " ")) @@ -452,9 +452,9 @@ func TestRunServer(t *testing.T) { time.Sleep(time.Second) } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // PRIVS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func capture(fn execable) ([]byte, error) { oldStdout := os.Stdout r, w, _ := os.Pipe() diff --git a/commands/route.go b/commands/route.go index 7e94ed3..839cdb2 100644 --- a/commands/route.go +++ b/commands/route.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/core" ) // add-route diff --git a/commands/server.go b/commands/server.go index 25318d7..c7bed07 100644 --- a/commands/server.go +++ b/commands/server.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/core" ) // server-add diff --git a/commands/service.go b/commands/service.go index b6cba4b..d0494ee 100644 --- a/commands/service.go +++ b/commands/service.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/core" ) // service-add diff --git a/commands/vip.go b/commands/vip.go index 3bfae6a..b91e60c 100644 --- a/commands/vip.go +++ b/commands/vip.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/core" ) // add-vip diff --git a/core/common/common.go b/core/common/common.go index e76c711..319b786 100644 --- a/core/common/common.go +++ b/core/common/common.go @@ -6,12 +6,12 @@ import ( "fmt" "strings" - "github.com/nanopack/portal/balance" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/database" - "github.com/nanopack/portal/proxymgr" - "github.com/nanopack/portal/vipmgr" + "github.com/mu-box/portal/balance" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/database" + "github.com/mu-box/portal/proxymgr" + "github.com/mu-box/portal/vipmgr" ) func SetServices(services []core.Service) error { diff --git a/database/database.go b/database/database.go index 7519c5d..ee335ee 100644 --- a/database/database.go +++ b/database/database.go @@ -6,8 +6,8 @@ import ( "fmt" "net/url" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) var ( diff --git a/database/postgres.go b/database/postgres.go index ffcc3c6..bcba215 100644 --- a/database/postgres.go +++ b/database/postgres.go @@ -9,8 +9,8 @@ import ( _ "github.com/lib/pq" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) type ( diff --git a/database/postgres_test.go b/database/postgres_test.go index 61123b1..5990db7 100644 --- a/database/postgres_test.go +++ b/database/postgres_test.go @@ -7,9 +7,9 @@ import ( "github.com/jcelliott/lumber" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/database" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/database" ) var ( diff --git a/database/scribble.go b/database/scribble.go index a9a8bff..fcbcee5 100644 --- a/database/scribble.go +++ b/database/scribble.go @@ -6,11 +6,11 @@ import ( "net/url" "strings" - "github.com/nanobox-io/golang-scribble" + scribble "github.com/mu-box/golang-scribble" "github.com/twinj/uuid" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) type ( diff --git a/database/scribble_test.go b/database/scribble_test.go index d8b70b1..521d234 100644 --- a/database/scribble_test.go +++ b/database/scribble_test.go @@ -8,9 +8,9 @@ import ( "github.com/jcelliott/lumber" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/database" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/database" ) var ( diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..aa9b923 --- /dev/null +++ b/go.mod @@ -0,0 +1,35 @@ +module github.com/mu-box/portal + +go 1.20 + +require ( + github.com/coreos/go-iptables v0.0.0-20151211183357-90456be57fcb + github.com/garyburd/redigo v0.0.0-20151219232044-836b6e58b335 + github.com/gorilla/pat v0.0.0-20160413041632-cf955c3d1f2c + github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25 + github.com/lib/pq v0.0.0-20160806144029-80f8150043c8 + github.com/mu-box/microbox-router v0.0.0-20180417202558-c2acc6938f80 + github.com/spf13/cobra v0.0.0-20160802223737-7c674d9e7201 + github.com/spf13/viper v0.0.0-20160508180713-d8a428b8a306 + github.com/twinj/uuid v0.0.0-20151029044442-89173bcdda19 +) + +require ( + github.com/BurntSushi/toml v0.1.1-0.20160102144748-5c4df71dfe9a // indirect + github.com/fsnotify/fsnotify v1.3.0 // indirect + github.com/gorilla/context v0.0.0-20150820051245-1c83b3eabd45 // indirect + github.com/gorilla/mux v0.0.0-20151231161908-26a6070f8499 // indirect + github.com/hashicorp/hcl v0.0.0-20151218175300-197e8d3cf421 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/magiconair/properties v1.6.1-0.20151221213149-c81f9d71af8f // indirect + github.com/mitchellh/mapstructure v0.0.0-20150717051158-281073eb9eb0 // indirect + github.com/nanobox-io/nanobox-router v0.0.0-20190311151444-8468a5929ca1 // indirect + github.com/spf13/cast v0.0.0-20151218135219-ee7b3e035316 // indirect + github.com/spf13/jwalterweatherman v0.0.0-20151231185856-d00654080cdd // indirect + github.com/spf13/pflag v0.0.0-20160427162146-cb88ea77998c // indirect + github.com/stretchr/testify v1.8.2 // indirect + golang.org/x/net v0.9.0 // indirect + golang.org/x/sys v0.7.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v2 v2.0.0-20150924142314-53feefa2559f // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..121f995 --- /dev/null +++ b/go.sum @@ -0,0 +1,71 @@ +github.com/BurntSushi/toml v0.1.1-0.20160102144748-5c4df71dfe9a h1:xrUE5z0ZdXKgezv7ImgqXATQ+tMal+fdF8fE7SE+gJA= +github.com/BurntSushi/toml v0.1.1-0.20160102144748-5c4df71dfe9a/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/coreos/go-iptables v0.0.0-20151211183357-90456be57fcb h1:cW2yWWWlgcppc2JKFdGbpJSMorMKxWFrpCnZmQDG2Z8= +github.com/coreos/go-iptables v0.0.0-20151211183357-90456be57fcb/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= +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/fsnotify/fsnotify v1.3.0 h1:XyNoRE4PlEAzjaHYBqJuJC18jNWyfDVJ2jwD5kCuwXs= +github.com/fsnotify/fsnotify v1.3.0/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/garyburd/redigo v0.0.0-20151219232044-836b6e58b335 h1:0HWFpTaeJuTBnYEXhYeUK9zin8uKnHDDN04aPrMJh7Y= +github.com/garyburd/redigo v0.0.0-20151219232044-836b6e58b335/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= +github.com/gorilla/context v0.0.0-20150820051245-1c83b3eabd45 h1:f69IpTg7NxbCoH51W7oD+gPkojLLvi6ybJ6Iya76wB8= +github.com/gorilla/context v0.0.0-20150820051245-1c83b3eabd45/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v0.0.0-20151231161908-26a6070f8499 h1:iRYRCSM6DM8YCobOA1unaW7SDpOaAbN48xmBnybfKhE= +github.com/gorilla/mux v0.0.0-20151231161908-26a6070f8499/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/pat v0.0.0-20160413041632-cf955c3d1f2c h1:/dq3+XpxRH+cjiua5GyJKE80RXZfZbmT8ejIcNsb93Q= +github.com/gorilla/pat v0.0.0-20160413041632-cf955c3d1f2c/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY= +github.com/hashicorp/hcl v0.0.0-20151218175300-197e8d3cf421 h1:Awdfz+Np2BzopipDcUT3tLRdSkFexLqPaptw/Er5lS4= +github.com/hashicorp/hcl v0.0.0-20151218175300-197e8d3cf421/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25 h1:EFT6MH3igZK/dIVqgGbTqWVvkZ7wJ5iGN03SVtvvdd8= +github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25/go.mod h1:sWkGw/wsaHtRsT9zGQ/WyJCotGWG/Anow/9hsAcBWRw= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lib/pq v0.0.0-20160806144029-80f8150043c8 h1:ymrmOy9nqFlWI+NXdLzvAUcQuYlOSqW2/UconD0I3BM= +github.com/lib/pq v0.0.0-20160806144029-80f8150043c8/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/magiconair/properties v1.6.1-0.20151221213149-c81f9d71af8f h1:i0qIYnnNb+u80O3KUCNlVOFezoKlKg1J96/XzTILLnI= +github.com/magiconair/properties v1.6.1-0.20151221213149-c81f9d71af8f/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mitchellh/mapstructure v0.0.0-20150717051158-281073eb9eb0 h1:6VeKv8nNMVKA6qmZLYnPTx0tJ//NbDj1SbubWIikJ9k= +github.com/mitchellh/mapstructure v0.0.0-20150717051158-281073eb9eb0/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mu-box/microbox-router v0.0.0-20180417202558-c2acc6938f80 h1:JzontkWR6K7IhACE4jdLnZYAIue0skzufaX1aWHx4QA= +github.com/mu-box/microbox-router v0.0.0-20180417202558-c2acc6938f80/go.mod h1:PnghhgvBEZl6o0RsFDs8prgmQ5XbAS30/qWOpnrUT5o= +github.com/nanobox-io/nanobox-router v0.0.0-20190311151444-8468a5929ca1 h1:rhrnErwXLQxLSqlxfQmHrudyNYaCiZGBxXk6u59RvUU= +github.com/nanobox-io/nanobox-router v0.0.0-20190311151444-8468a5929ca1/go.mod h1:ido3i70D8uGeSq5rmYxo2rrctc9ZFy1ALlTVxThiI0U= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spf13/cast v0.0.0-20151218135219-ee7b3e035316 h1:ewDvguiDYTmhbP+hILV+IplQQM88stMcBcjFOPV7lSE= +github.com/spf13/cast v0.0.0-20151218135219-ee7b3e035316/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= +github.com/spf13/cobra v0.0.0-20160802223737-7c674d9e7201 h1:bgbdfQ1FHk/ZcoUOsN25tfKEXeJBUZYggLw6PSfO5iA= +github.com/spf13/cobra v0.0.0-20160802223737-7c674d9e7201/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/jwalterweatherman v0.0.0-20151231185856-d00654080cdd h1:9bF+yGiaGsgj11cktC7g+ir97H+vzvSvXv6asp/f0rs= +github.com/spf13/jwalterweatherman v0.0.0-20151231185856-d00654080cdd/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v0.0.0-20160427162146-cb88ea77998c h1:nKSqf1F72lP/EWecUpeCXINWfP8aAa5TXORk21x0xw8= +github.com/spf13/pflag v0.0.0-20160427162146-cb88ea77998c/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v0.0.0-20160508180713-d8a428b8a306 h1:fvXBhJjS/jLG2A5yTggvllwqmgL4P6n6M9BKw1PIFmY= +github.com/spf13/viper v0.0.0-20160508180713-d8a428b8a306/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/twinj/uuid v0.0.0-20151029044442-89173bcdda19 h1:HlxV0XiEKMMyjS3gGtJmmFZsxQ22GsLvA7F980il+1w= +github.com/twinj/uuid v0.0.0-20151029044442-89173bcdda19/go.mod h1:mMgcE1RHFUFqe5AfiwlINXisXfDGro23fWdPUfOMjRY= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v2 v2.0.0-20150924142314-53feefa2559f h1:sOheF02XWNGQor9t3gRZtN/HlgP6sv3NozSahoTEmiM= +gopkg.in/yaml.v2 v2.0.0-20150924142314-53feefa2559f/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 1efc3f9..c175831 100644 --- a/main.go +++ b/main.go @@ -1,121 +1,115 @@ // -*- mode: go; tab-width: 2; indent-tabs-mode: 1; st-rulers: [70] -*- // vim: ts=4 sw=4 ft=lua noet -//-------------------------------------------------------------------- -// @author Daniel Barney -// @author Greg Linton -// @copyright 2016, Pagoda Box Inc. -// @doc -// -// @end -// Created : 7 August 2015 by Daniel Barney -// Refactored : March 2016 by Greg Linton -//-------------------------------------------------------------------- // Portal is an api-driven, in-kernel layer 2/3 load balancer with // http/s proxy cababilities. // -// Usage +// # Usage // // To run as a server, using the defaults, starting portal is as simple as -// portal -s +// +// portal -s +// // For more specific usage information, refer to the help doc (portal -h): // -// Usage: -// portal [flags] -// portal [command] -// -// Available Commands: -// add-service Add service -// remove-service Remove service -// show-service Show service -// show-services Show all services -// set-services Set service list -// set-service Set service -// add-server Add server to a service -// remove-server Remove server from a service -// show-server Show server on a service -// show-servers Show all servers on a service -// set-servers Set server list on a service -// add-route Add route -// set-routes Set route list -// show-routes Show all routes -// remove-route Remove route -// add-cert Add cert -// set-certs Set cert list -// show-certs Show all certs -// remove-cert Remove cert -// -// Flags: -// -C, --api-cert="": SSL cert for the api -// -H, --api-host="127.0.0.1": Listen address for the API -// -k, --api-key="": SSL key for the api -// -p, --api-key-password="": Password for the SSL key -// -P, --api-port="8443": Listen address for the API -// -t, --api-token="": Token for API Access -// -b, --balancer="lvs": Load balancer to use (nginx|lvs) -// -r, --cluster-connection="none://": Cluster connection string (redis://127.0.0.1:6379) -// -T, --cluster-token="": Cluster security token -// -c, --conf="": Configuration file to load -// -d, --db-connection="scribble:///var/db/portal": Database connection string -// -i, --insecure[=false]: Disable tls key checking (client) and listen on http (server) -// -j, --just-proxy[=false]: Proxy only (no tcp/udp load balancing) -// -L, --log-file="": Log file to write to -// -l, --log-level="INFO": Log level to output -// -x, --proxy-http="0.0.0.0:80": Address to listen on for proxying http -// -X, --proxy-tls="0.0.0.0:443": Address to listen on for proxying https -// -s, --server[=false]: Run in server mode -// -v, --version[=false]: Print version info and exit -// -w, --work-dir="/var/db/portal": Directory for portal to use (balancer config) -// -// Use "portal [command] --help" for more information about a command. -// -// -// Build Specs +// Usage: +// portal [flags] +// portal [command] +// +// Available Commands: +// add-service Add service +// remove-service Remove service +// show-service Show service +// show-services Show all services +// set-services Set service list +// set-service Set service +// add-server Add server to a service +// remove-server Remove server from a service +// show-server Show server on a service +// show-servers Show all servers on a service +// set-servers Set server list on a service +// add-route Add route +// set-routes Set route list +// show-routes Show all routes +// remove-route Remove route +// add-cert Add cert +// set-certs Set cert list +// show-certs Show all certs +// remove-cert Remove cert +// +// Flags: +// -C, --api-cert="": SSL cert for the api +// -H, --api-host="127.0.0.1": Listen address for the API +// -k, --api-key="": SSL key for the api +// -p, --api-key-password="": Password for the SSL key +// -P, --api-port="8443": Listen address for the API +// -t, --api-token="": Token for API Access +// -b, --balancer="lvs": Load balancer to use (nginx|lvs) +// -r, --cluster-connection="none://": Cluster connection string (redis://127.0.0.1:6379) +// -T, --cluster-token="": Cluster security token +// -c, --conf="": Configuration file to load +// -d, --db-connection="scribble:///var/db/portal": Database connection string +// -i, --insecure[=false]: Disable tls key checking (client) and listen on http (server) +// -j, --just-proxy[=false]: Proxy only (no tcp/udp load balancing) +// -L, --log-file="": Log file to write to +// -l, --log-level="INFO": Log level to output +// -x, --proxy-http="0.0.0.0:80": Address to listen on for proxying http +// -X, --proxy-tls="0.0.0.0:443": Address to listen on for proxying https +// -s, --server[=false]: Run in server mode +// -v, --version[=false]: Print version info and exit +// -w, --work-dir="/var/db/portal": Directory for portal to use (balancer config) +// +// Use "portal [command] --help" for more information about a command. +// +// # Build Specs // // It is built with clustering at it's core -// to ensure syncronization between nodes. It utilizes a multi-master +// to ensure syncronization between nodes. It utilizes a multi-primary // replication system allowing any node to accept requests to update // load balancing or proxy rules. The high-level workflow is as follows: // -// // every call starts by hitting the api -// API - setRoute -// - calls cluster.SetRoute +// // every call starts by hitting the api +// API - setRoute +// - calls cluster.SetRoute // -// // in order to ensure syncronization comes first, cluster starts the work -// CLUSTER - SetRoute -// - calls publish "set-route" +// // in order to ensure syncronization comes first, cluster starts the work +// CLUSTER - SetRoute +// - calls publish "set-route" // -// // the redis clusterer utilizes the pub/sub functionality for syncronization -// // when it recieves a message, it calls on "common" to implement the changes -// SUBSCRIBER - on "set-route" -// - calls common.SetRoute +// // the redis clusterer utilizes the pub/sub functionality for syncronization +// // when it recieves a message, it calls on "common" to implement the changes +// SUBSCRIBER - on "set-route" +// - calls common.SetRoute // -// // common contains all the logic to perform an action, as well as roll back -// // other "systems" upon failure, effectively "undoing" the action -// COMMON - SetRoute -// - calls proxymgr.SetRoute & database.SetRoute -// - rolls back proxymgr if database fails +// // common contains all the logic to perform an action, as well as roll back +// // other "systems" upon failure, effectively "undoing" the action +// COMMON - SetRoute +// - calls proxymgr.SetRoute & database.SetRoute +// - rolls back proxymgr if database fails // -// SUBSCRIBER -// - if common.SetRoute was successful, write success to redis for self, otherwise -// rollback self +// SUBSCRIBER +// - if common.SetRoute was successful, write success to redis for self, otherwise +// rollback self // -// // the cluster member that received the request ensures all members got the update -// CLUSTER -// - returns err if not all members have set route -// - rolls back `common` (via publish) if not all members can set route +// // the cluster member that received the request ensures all members got the update +// CLUSTER +// - returns err if not all members have set route +// - rolls back `common` (via publish) if not all members can set route // -// API -// - if error, return 500 response, otherwise respond as fits +// API +// - if error, return 500 response, otherwise respond as fits // // Portal is also extremely "pluggable", meaning that it is easy to code in // another tool to be a "Balancer" or "Proxy" by matching the interfaces. // Individual object (database|balancer|proxy) functions are never called // directly by "common". "Common" calls package level functions such as -// database.SetService +// +// database.SetService +// // which calls/sreturns the selected "Backend's" SetService function. // The type of backend (scribble/redis) is determined from the connection // configuration option, as seen in the package's Init() function: +// // url, err := url.Parse(config.ClusterConnection) // if err != nil { // return fmt.Errorf("Failed to parse db connection - %s", err) @@ -136,7 +130,7 @@ package main import ( "fmt" - "github.com/nanopack/portal/commands" + "github.com/mu-box/portal/commands" ) func main() { diff --git a/proxymgr/nanobox.go b/proxymgr/microbox.go similarity index 85% rename from proxymgr/nanobox.go rename to proxymgr/microbox.go index f3d6f26..5687963 100644 --- a/proxymgr/nanobox.go +++ b/proxymgr/microbox.go @@ -1,4 +1,4 @@ -// nanobox.go contains logic to use nanobox-router as a proxy +// microbox.go contains logic to use microbox-router as a proxy package proxymgr @@ -6,16 +6,16 @@ import ( "fmt" "github.com/jcelliott/lumber" - "github.com/nanobox-io/nanobox-router" + router "github.com/mu-box/microbox-router" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) -type Nanobox struct{} +type Microbox struct{} -func (self Nanobox) Init() error { - // we want to see nanobox-router logs +func (self Microbox) Init() error { + // we want to see microbox-router logs lumber.Level(lumber.LvlInt(config.LogLevel)) // configure upstream cert checks @@ -28,7 +28,7 @@ func (self Nanobox) Init() error { } config.Log.Info("Proxy listening at http://%s...", config.RouteHttp) - // set a default cert (*.nanoapp.io) self signed + // set a default cert (*.microbox.app) self signed err = self.SetDefaultCert(core.CertBundle{Cert: "-----BEGIN CERTIFICATE-----\nMIIDnzCCAoegAwIBAgIJAMoiK3cYcT01MA0GCSqGSIb3DQEBCwUAMGYxCzAJBgNV\nBAYTAlVTMQ4wDAYDVQQIDAVJZGFobzEQMA4GA1UEBwwHUmV4YnVyZzEQMA4GA1UE\nCgwHTmFub2JveDEMMAoGA1UECwwDT3JnMRUwEwYDVQQDDAwqLm5hbm9hcHAuaW8w\nHhcNMTgwNDExMjIxNjEzWhcNMjgwNDA4MjIxNjEzWjBmMQswCQYDVQQGEwJVUzEO\nMAwGA1UECAwFSWRhaG8xEDAOBgNVBAcMB1JleGJ1cmcxEDAOBgNVBAoMB05hbm9i\nb3gxDDAKBgNVBAsMA09yZzEVMBMGA1UEAwwMKi5uYW5vYXBwLmlvMIIBIjANBgkq\nhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvKzIzdVw25whbmrFYLWg+D/xT0Smzli8\nc8vwXwcpx6XXcBcNdagAoxXy4zxjrYHkin0TxLJWNELNlBPkXt7GHJoe0/pbn9Iq\nnpJw1asi0VXGDO4ne+J7q+aUbpshpWG2NE9KEi1LFNfYnNLwvVkAylrmBLYXbdhN\nuWT164PtjEcT1mx3RNR4l8Zey3RgrBXp3y61ePFwPrHTM3t/AQixTPzU5UzArYJI\neEgFJe2cltuwLezLaXisR3IS42m3oBP1toAb6xM+wgznwQnByjCJy75658QGccJ9\npseIZBDYeArYDBcNUjW2Gp//vdDBRyYCn7bAJ9MHAOyHB50eWGLmMwIDAQABo1Aw\nTjAdBgNVHQ4EFgQUyMdlMFwMjKcBxPWC8vUhuQZ9iUYwHwYDVR0jBBgwFoAUyMdl\nMFwMjKcBxPWC8vUhuQZ9iUYwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC\nAQEALfJe6r2XD/93ZPNOhU6uyTvLkVKTIiE9E1NC5/bqhtHg8XVUR6kp2wwOH0Td\nMdop8XuhZDsZ5kGV9f8UA5s2Q2SFk9Nyu5gNmtVxVUrUb2yWwNmYVoxH+ntvthaK\nfH2lkgqXVQbFU5qYS+Vt4oxhb3ox0cxMkFJ5UsHzL2+8vZfzzL42g7WAolYOdXuo\nh+sLnKQfnqbYSdjyRGDu/uwyoZidrk7bZ2CQIIAKEF3kYDq29Y8zNRXKng83pS/3\nBx/nDgQW4+AAHm7YmfdbzcLLi4oW8lMb6fMW5DrOZ2pbfpSGGb6r1EVP8cHxLUso\n+nefsCWniPqS+FAxsXTxMvVLKA==\n-----END CERTIFICATE-----\n", Key: "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC8rMjN1XDbnCFu\nasVgtaD4P/FPRKbOWLxzy/BfBynHpddwFw11qACjFfLjPGOtgeSKfRPEslY0Qs2U\nE+Re3sYcmh7T+luf0iqeknDVqyLRVcYM7id74nur5pRumyGlYbY0T0oSLUsU19ic\n0vC9WQDKWuYEthdt2E25ZPXrg+2MRxPWbHdE1HiXxl7LdGCsFenfLrV48XA+sdMz\ne38BCLFM/NTlTMCtgkh4SAUl7ZyW27At7MtpeKxHchLjabegE/W2gBvrEz7CDOfB\nCcHKMInLvnrnxAZxwn2mx4hkENh4CtgMFw1SNbYan/+90MFHJgKftsAn0wcA7IcH\nnR5YYuYzAgMBAAECggEAOiI+6PUIBhKQVnY9hLPR+kuxbYwonVHIFyHSWWVaoTJf\nNCFWO1ddguKDaTK1P8PTCDzLt4J/fzDKKQMMDZM0laGDOCteydq22Q8kByHo43k7\nQcarkcdR9cBhIcdY0Z1Ox8VafElKZgyvqHpyRNVEohTp5K+6flT0ddg+0adfrSW9\n7ilafXKX1976BQWeS2j5AUsaw9qWTMz/QhjYDvvYHsEG6rZFnUbQn+k65ubLOqG8\nYHj5z9Y7EZP/GfsByMgdyTLSnynz5ifzt05yeCUIEEhqsN1NZEMh8wfhzMCAnqYo\nRWujn5hayFmdZhXMiiBTSCUq52HPucOw5IXFfjnzSQKBgQDdNicOtx/o2j0QgzHo\ngB2tyieao+nlleQyK06xgRz/xjiRyObRuRpTYB1f6lyWKjwn5gdCnsj2JyUO0UAr\n7Xpc8suESyFbKBJ8QlYfagB72QN5k2NlxNE8kXSDruSS5Cu8N3OX025sFTuwiOhB\nmV3LU5VWvjcEs2T8goaMmGCV/QKBgQDaWLo8yvM19sc8z/3D4eQFcCQFlbz0/qPR\nPm8hWhd+U5KIKCKi4b03RnedJ8SSIHGM5JNKbsXVzCIOLOKq+eNCabYxI4TfgVWw\nIOXKOg9EdUdpHjf0V0kVFvl6bKcjkv/k51bVqjzeoeE8/iAiEWRmTNjyFVt3NXzB\nuncih2kL7wKBgQCIcUlf+zXUYx/9Gl7jQHqN4j3RVT8EnBKXmzy7oZ6oaLQlv5wX\nSaviN0uHCMA44y4dkfVycwwTQAvMeuaw8ZZi1GMRY2Hcnvff6u7CC5jmyvEowO8z\nK1W/nRwXyP01WUVcn3tN71yRj/s0JQ3UwGso6ZIYYdT/skMcuMmS2L3iZQKBgQCm\nb6Pm2zzxEZ9lt5XUTsglbQnISA+1ILV2toS3g5kM7l9v8kgUqMY28DwVS08HpDtq\nDoJH5pBfHC+JZqWRdtHIuhPq+Qw74raSf0EqGX+xy0QX2LUGR9KphM2+iDwPXeo5\nbi4+yHmFqxeqCnwr+93wLPvh7G3APMFQWvadF2L3eQKBgQC7zGqilReyuPleRkc6\nud4YweWzLov2IOK4JM/2c6AxzhRzuIMMDEPFbEGSIKPNSabclBf/kdqySYy/ZbGO\nnQ2Z+hPmCf7hfXZBGdEvR/WRkohQE6WdD7jKc2mYgQCIv8AR7yr9Bau4fs1LQLCc\nmm1hHKbUb5R8edPKixtXWKowLA==\n-----END PRIVATE KEY-----\n"}) if err != nil { @@ -52,7 +52,7 @@ func (self Nanobox) Init() error { // ROUTES //////////////////////////////////////////////////////////////////////////////// -func (self Nanobox) SetRoute(route core.Route) error { +func (self Microbox) SetRoute(route core.Route) error { routes := router.Routes() // for idempotency for i := range routes { @@ -65,7 +65,7 @@ func (self Nanobox) SetRoute(route core.Route) error { return self.SetRoutes(self.routesToR(routes)) } -func (self Nanobox) DeleteRoute(route core.Route) error { +func (self Microbox) DeleteRoute(route core.Route) error { routes := router.Routes() for i := range routes { if routes[i].SubDomain == route.SubDomain && routes[i].Domain == route.Domain && routes[i].Path == route.Path { @@ -76,11 +76,11 @@ func (self Nanobox) DeleteRoute(route core.Route) error { return self.SetRoutes(self.routesToR(routes)) } -func (self Nanobox) SetRoutes(routes []core.Route) error { +func (self Microbox) SetRoutes(routes []core.Route) error { return router.UpdateRoutes(self.rToRoutes(routes)) } -func (self Nanobox) GetRoutes() ([]core.Route, error) { +func (self Microbox) GetRoutes() ([]core.Route, error) { return self.routesToR(router.Routes()), nil } @@ -88,7 +88,7 @@ func (self Nanobox) GetRoutes() ([]core.Route, error) { // CERTS //////////////////////////////////////////////////////////////////////////////// -func (self Nanobox) SetCert(cert core.CertBundle) error { +func (self Microbox) SetCert(cert core.CertBundle) error { certs := router.Keys() // for idempotency for i := range certs { @@ -102,11 +102,11 @@ func (self Nanobox) SetCert(cert core.CertBundle) error { return self.SetCerts(self.keysToC(certs)) } -func (self Nanobox) SetDefaultCert(cert core.CertBundle) error { +func (self Microbox) SetDefaultCert(cert core.CertBundle) error { return router.SetDefaultCert(cert.Cert, cert.Key) } -func (self Nanobox) DeleteCert(cert core.CertBundle) error { +func (self Microbox) DeleteCert(cert core.CertBundle) error { certs := router.Keys() for i := range certs { if certs[i].Cert == cert.Cert && certs[i].Key == cert.Key { @@ -118,15 +118,15 @@ func (self Nanobox) DeleteCert(cert core.CertBundle) error { return self.SetCerts(self.keysToC(certs)) } -func (self Nanobox) SetCerts(certs []core.CertBundle) error { +func (self Microbox) SetCerts(certs []core.CertBundle) error { return router.UpdateCerts(self.cToKeys(certs)) } -func (self Nanobox) GetCerts() ([]core.CertBundle, error) { +func (self Microbox) GetCerts() ([]core.CertBundle, error) { return self.keysToC(router.Keys()), nil } -func (self Nanobox) cToKeys(certs []core.CertBundle) []router.KeyPair { +func (self Microbox) cToKeys(certs []core.CertBundle) []router.KeyPair { var keyPairs []router.KeyPair for i := range certs { keyPairs = append(keyPairs, router.KeyPair{Key: certs[i].Key, Cert: certs[i].Cert}) @@ -134,7 +134,7 @@ func (self Nanobox) cToKeys(certs []core.CertBundle) []router.KeyPair { return keyPairs } -func (self Nanobox) keysToC(certs []router.KeyPair) []core.CertBundle { +func (self Microbox) keysToC(certs []router.KeyPair) []core.CertBundle { var keyPairs []core.CertBundle for i := range certs { keyPairs = append(keyPairs, core.CertBundle{Key: certs[i].Key, Cert: certs[i].Cert}) @@ -142,7 +142,7 @@ func (self Nanobox) keysToC(certs []router.KeyPair) []core.CertBundle { return keyPairs } -func (self Nanobox) rToRoutes(routes []core.Route) []router.Route { +func (self Microbox) rToRoutes(routes []core.Route) []router.Route { var rts []router.Route for i := range routes { rts = append(rts, router.Route{ @@ -164,7 +164,7 @@ func (self Nanobox) rToRoutes(routes []core.Route) []router.Route { return rts } -func (self Nanobox) routesToR(routes []router.Route) []core.Route { +func (self Microbox) routesToR(routes []router.Route) []core.Route { var rts []core.Route for i := range routes { rts = append(rts, core.Route{ @@ -186,10 +186,10 @@ func (self Nanobox) routesToR(routes []router.Route) []core.Route { return rts } -func (self Nanobox) cToKey(cert core.CertBundle) router.KeyPair { +func (self Microbox) cToKey(cert core.CertBundle) router.KeyPair { return router.KeyPair{Key: cert.Key, Cert: cert.Cert} } -func (self Nanobox) rToRoute(route core.Route) router.Route { +func (self Microbox) rToRoute(route core.Route) router.Route { return router.Route{SubDomain: route.SubDomain, Domain: route.Domain, Path: route.Path, Targets: route.Targets, FwdPath: route.FwdPath, Page: route.Page} } diff --git a/proxymgr/proxymgr.go b/proxymgr/proxymgr.go index 87bd4e2..212a14a 100644 --- a/proxymgr/proxymgr.go +++ b/proxymgr/proxymgr.go @@ -3,7 +3,7 @@ // handles the adding of 'certs' (key/cert sets) for a secure reverse proxy router package proxymgr -import "github.com/nanopack/portal/core" +import "github.com/mu-box/portal/core" type proxyable interface { Init() error @@ -15,7 +15,7 @@ var ( ) func Init() error { - Proxy = &Nanobox{} + Proxy = &Microbox{} return Proxy.Init() } diff --git a/proxymgr/proxymgr_test.go b/proxymgr/proxymgr_test.go index 4a3e985..41afa04 100644 --- a/proxymgr/proxymgr_test.go +++ b/proxymgr/proxymgr_test.go @@ -7,9 +7,9 @@ import ( "github.com/jcelliott/lumber" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" - "github.com/nanopack/portal/proxymgr" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" + "github.com/mu-box/portal/proxymgr" ) var ( @@ -25,9 +25,9 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // ROUTES -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetRoute(t *testing.T) { if err := proxymgr.SetRoute(testRoute); err != nil { t.Errorf("Failed to SET route - %s", err) @@ -93,9 +93,9 @@ func TestDeleteRoute(t *testing.T) { } } -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// // CERTS -//////////////////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////////////////// func TestSetCert(t *testing.T) { if err := proxymgr.SetCert(testCert); err != nil { t.Errorf("Failed to SET cert - %s", err) diff --git a/reqs.txt b/reqs.txt deleted file mode 100644 index eb0cc78..0000000 --- a/reqs.txt +++ /dev/null @@ -1,22 +0,0 @@ -github.com/coreos/go-iptables/iptables 90456be -github.com/garyburd/redigo/redis 836b6e5 -github.com/gorilla/pat e3ceaad -github.com/jcelliott/lumber dd34944 -github.com/lib/pq 80f8150 -github.com/nanobox-io/golang-lvs 9b5dfa7 -github.com/nanobox-io/golang-nanoauth c65e52a -github.com/nanobox-io/golang-scribble 2a34006 -github.com/nanobox-io/nanobox-router fd3a5ec -github.com/nanopack/portal/api 608581a -github.com/nanopack/portal/balance 608581a -github.com/nanopack/portal/cluster 608581a -github.com/nanopack/portal/commands 608581a -github.com/nanopack/portal/config 608581a -github.com/nanopack/portal/core 608581a -github.com/nanopack/portal/core/common 608581a -github.com/nanopack/portal/database 608581a -github.com/nanopack/portal/proxymgr 608581a -github.com/nanopack/portal/vipmgr 608581a -github.com/spf13/cobra 7c674d9 -github.com/spf13/viper d8a428b -github.com/twinj/uuid 89173bc diff --git a/scripts/build.sh b/scripts/build.sh index 8b481dd..dcce5d1 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -25,8 +25,8 @@ echo "Building portal..." # export PATH=/usr/local/go-1.7.6/bin:$PATH # should be built with go1.7.x until tls regression is resolved. also https://github.com/golang/go/issues/21133 -gox -ldflags="-s -X github.com/nanopack/portal/commands.tag=$(getCurrTag) - -X github.com/nanopack/portal/commands.commit=$(getCurrCommit)" \ +gox -ldflags="-s -X github.com/mu-box/portal/commands.tag=$(getCurrTag) + -X github.com/mu-box/portal/commands.commit=$(getCurrCommit)" \ -osarch "linux/amd64" -output="./build/{{.OS}}/{{.Arch}}/portal" # -osarch "darwin/amd64 linux/amd64 windows/amd64" -output="./build/{{.OS}}/{{.Arch}}/portal" diff --git a/scripts/upload.sh b/scripts/upload.sh index 2ac353e..bc2a3ab 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -3,10 +3,10 @@ set -e # upload to AWS S3 echo "Uploading builds to S3..." -aws s3 sync ./build/ s3://tools.nanopack.io/portal --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --region us-east-1 +aws s3 sync ./build/ s3://tools.microbox.cloud/portal --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --region us-east-1 -echo "Creating invalidation for cloudfront" -aws configure set preview.cloudfront true -aws cloudfront create-invalidation \ - --distribution-id E3B5Z3LYG19QSL \ - --paths /portal +# echo "Creating invalidation for cloudfront" +# aws configure set preview.cloudfront true +# aws cloudfront create-invalidation \ +# --distribution-id E3B5Z3LYG19QSL \ +# --paths /portal diff --git a/vendor/vendor.json b/vendor/vendor.json deleted file mode 100644 index 97741df..0000000 --- a/vendor/vendor.json +++ /dev/null @@ -1,217 +0,0 @@ -{ - "comment": "", - "ignore": "test", - "package": [ - { - "checksumSHA1": "3xEzE5vH/UVyyB3YSzEcr2MAZqw=", - "path": "github.com/BurntSushi/toml", - "revision": "5c4df71dfe9ac89ef6287afc05e4c1b16ae65a1e", - "revisionTime": "2016-01-02T14:47:48Z" - }, - { - "checksumSHA1": "7qlsW0pXrPI6T2z2jbR4lEKPO/s=", - "path": "github.com/coreos/go-iptables/iptables", - "revision": "90456be57fcb8185b264b77ce42a9539df42df25", - "revisionTime": "2015-12-11T18:33:57Z" - }, - { - "checksumSHA1": "LtBBfn+Uw7/gaB2tVsrLRBTprdo=", - "path": "github.com/fsnotify/fsnotify", - "revision": "30411dbcefb7a1da7e84f75530ad3abe4011b4f8", - "revisionTime": "2016-04-12T13:37:56Z" - }, - { - "checksumSHA1": "2UmMbNHc8FBr98mJFN1k8ISOIHk=", - "path": "github.com/garyburd/redigo/internal", - "revision": "836b6e58b3358112c8291565d01c35b8764070d7", - "revisionTime": "2015-12-19T23:20:44Z" - }, - { - "checksumSHA1": "rD2qkFpmML4hNlIHQugTrrhgMtY=", - "path": "github.com/garyburd/redigo/redis", - "revision": "836b6e58b3358112c8291565d01c35b8764070d7", - "revisionTime": "2015-12-19T23:20:44Z" - }, - { - "checksumSHA1": "iIUYZyoanCQQTUaWsu8b+iOSPt4=", - "path": "github.com/gorilla/context", - "revision": "1c83b3eabd45b6d76072b66b746c20815fb2872d", - "revisionTime": "2015-08-20T05:12:45Z" - }, - { - "checksumSHA1": "DOGELl/eJ66TomAnkQqKminijQU=", - "path": "github.com/gorilla/mux", - "revision": "26a6070f849969ba72b72256e9f14cf519751690", - "revisionTime": "2015-12-31T16:19:08Z" - }, - { - "checksumSHA1": "41syjEeyv9W/6j89XArd1yyWNBU=", - "path": "github.com/gorilla/pat", - "revision": "cf955c3d1f2c27ee96f93e9738085c762ff5f49d", - "revisionTime": "2016-04-13T04:16:32Z" - }, - { - "checksumSHA1": "RqlXnqTJnV68iQmiDMaOMhtj7VY=", - "path": "github.com/hashicorp/hcl", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "zDgf1+QB7Fvg8b7Z/0GnmoQ22yw=", - "path": "github.com/hashicorp/hcl/hcl/ast", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "Bp6ftbfyrMdHvLlzcNsLQH+Xqw4=", - "path": "github.com/hashicorp/hcl/hcl/parser", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "AwXW3BDC53INB5cY2CLmtIFfOPw=", - "path": "github.com/hashicorp/hcl/hcl/scanner", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "wh2mSXMC88JiAy8FIrTtL7OmY7Q=", - "path": "github.com/hashicorp/hcl/hcl/strconv", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "mCxZsnCaqyKhAC5iulJQpt8LIqA=", - "path": "github.com/hashicorp/hcl/hcl/token", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "uEaK2zagnGctsUmjWt8ZYmK1Yvs=", - "path": "github.com/hashicorp/hcl/json/parser", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "S1e0F9ZKSnqgOLfjDTYazRL28tA=", - "path": "github.com/hashicorp/hcl/json/scanner", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "fNlXQCQEnb+B3k5UDL/r15xtSJY=", - "path": "github.com/hashicorp/hcl/json/token", - "revision": "197e8d3cf42199cfd53cd775deb37f3637234635", - "revisionTime": "2015-12-18T17:53:00Z" - }, - { - "checksumSHA1": "40vJyUB4ezQSn/NSadsKEOrudMc=", - "path": "github.com/inconshreveable/mousetrap", - "revision": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75", - "revisionTime": "2014-10-17T20:07:13Z" - }, - { - "checksumSHA1": "TW1TbIL4RRT4fpdvwVxph25vdKw=", - "path": "github.com/jcelliott/lumber", - "revision": "dd349441af25132d146d7095c6693a15431fc9b1", - "revisionTime": "2016-03-24T20:37:08Z" - }, - { - "checksumSHA1": "dNYxHiBLalTqluak2/Z8c3RsSEM=", - "path": "github.com/lib/pq", - "revision": "80f8150043c80fb52dee6bc863a709cdac7ec8f8", - "revisionTime": "2016-08-06T14:40:29Z" - }, - { - "checksumSHA1": "xppHi82MLqVx1eyQmbhTesAEjx8=", - "path": "github.com/lib/pq/oid", - "revision": "80f8150043c80fb52dee6bc863a709cdac7ec8f8", - "revisionTime": "2016-08-06T14:40:29Z" - }, - { - "checksumSHA1": "KCgFx/QQG9vUtshnL9aUxeWGFyY=", - "path": "github.com/magiconair/properties", - "revision": "c81f9d71af8f8cba1466501d30326b99a4e56c19", - "revisionTime": "2015-12-21T21:31:49Z" - }, - { - "checksumSHA1": "4Js6Jlu93Wa0o6Kjt393L9Z7diE=", - "path": "github.com/mitchellh/mapstructure", - "revision": "281073eb9eb092240d33ef253c404f1cca550309", - "revisionTime": "2015-07-17T05:11:58Z" - }, - { - "checksumSHA1": "xce3mdPNp1O03qfiUk9zSrHrhqc=", - "path": "github.com/nanobox-io/golang-lvs", - "revision": "9b5dfa7cde3604dcb68984ef3697fb9e02378507", - "revisionTime": "2016-02-05T00:45:29Z" - }, - { - "checksumSHA1": "1GRIFd6tEXuuQll7oav7S3UdYE0=", - "path": "github.com/nanobox-io/golang-nanoauth", - "revision": "d48ad8ddeaf0cc843f887bbb78cd05e79cc1d669", - "revisionTime": "2016-10-26T18:18:52Z" - }, - { - "checksumSHA1": "edCO20GDXYpNfBM43TzCBaaPxCQ=", - "path": "github.com/nanobox-io/golang-scribble", - "revision": "da3a159a462297745592fd615d4bcebec94b54c6", - "revisionTime": "2017-03-27T21:44:30Z" - }, - { - "checksumSHA1": "jDk3nWOJ65BvG565AOLya8kwH1s=", - "path": "github.com/nanobox-io/nanobox-router", - "revision": "c2acc6938f802410c38560b6497d563dd615ae11", - "revisionTime": "2018-04-17T20:25:58Z" - }, - { - "checksumSHA1": "65+hx0QlLzpWe5pnjAzteKBnC10=", - "path": "github.com/spf13/cast", - "revision": "ee7b3e0353166ab1f3a605294ac8cd2b77953778", - "revisionTime": "2015-11-26T06:42:19Z" - }, - { - "checksumSHA1": "hvkXE4HQ2zgWaCkt3CQTki5hvqc=", - "path": "github.com/spf13/cobra", - "revision": "7c674d9e72017ed25f6d2b5e497a1368086b6a6f", - "revisionTime": "2016-08-02T22:37:37Z" - }, - { - "checksumSHA1": "88nY1XQWDuufclM+CiLeSxtVtaQ=", - "path": "github.com/spf13/jwalterweatherman", - "revision": "d00654080cddbd2b082acaa74007cb94a2b40866", - "revisionTime": "2015-10-14T07:12:31Z" - }, - { - "checksumSHA1": "s0GYwa3YNJJXON/b+6ci2Sz9mEw=", - "path": "github.com/spf13/pflag", - "revision": "cb88ea77998c3f024757528e3305022ab50b43be", - "revisionTime": "2016-03-17T00:02:28Z" - }, - { - "checksumSHA1": "6FPvEfscRGGViU4vyehlLyWFePw=", - "path": "github.com/spf13/viper", - "revision": "d8a428b8a30606e1d0b355d91edf282609ade1a6", - "revisionTime": "2016-05-08T18:07:13Z" - }, - { - "checksumSHA1": "76U6GiRZsKjr9OWohbsdfKPok/E=", - "path": "github.com/twinj/uuid", - "revision": "89173bcdda19db0eb88aef1e1cb1cb2505561d31", - "revisionTime": "2015-10-29T04:44:42Z" - }, - { - "checksumSHA1": "CoRxz7vk573Zu/UcMS4PzpAsv3w=", - "path": "golang.org/x/sys/unix", - "revision": "b776ec39b3e54652e09028aaaaac9757f4f8211a", - "revisionTime": "2016-04-21T02:29:30Z" - }, - { - "checksumSHA1": "Hs7pfHDSvTNtnRogAAziW2Lki3M=", - "path": "gopkg.in/yaml.v2", - "revision": "53feefa2559fb8dfa8d81baad31be332c97d6c77", - "revisionTime": "2015-09-24T14:23:14Z" - } - ], - "rootPath": "github.com/nanopack/portal" -} diff --git a/vipmgr/ip.go b/vipmgr/ip.go index a92ff53..2382af5 100644 --- a/vipmgr/ip.go +++ b/vipmgr/ip.go @@ -1,4 +1,6 @@ +//go:build linux // +build linux + // ip.go contains logic to use `ip` to add vips package vipmgr @@ -8,8 +10,8 @@ import ( "os/exec" "sync" - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) type ip struct{} diff --git a/vipmgr/ip_fake.go b/vipmgr/ip_fake.go index f2fee52..23814b5 100644 --- a/vipmgr/ip_fake.go +++ b/vipmgr/ip_fake.go @@ -1,11 +1,13 @@ +//go:build windows || darwin // +build windows darwin + // this fake lvs enables portal to compile for darwin/windows package vipmgr import ( - "github.com/nanopack/portal/config" - "github.com/nanopack/portal/core" + "github.com/mu-box/portal/config" + "github.com/mu-box/portal/core" ) type ip struct{} diff --git a/vipmgr/vipmgr.go b/vipmgr/vipmgr.go index e9bc904..581cec1 100644 --- a/vipmgr/vipmgr.go +++ b/vipmgr/vipmgr.go @@ -1,7 +1,7 @@ // vipmgr handles the adding of 'vips' package vipmgr -import "github.com/nanopack/portal/core" +import "github.com/mu-box/portal/core" type vipable interface { Init() error