Skip to content

Commit

Permalink
Update Actions, require Go 1.22 to drop mux
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Feb 16, 2024
1 parent 514be0b commit 37a2a66
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 39 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/go.yml
Expand Up @@ -15,12 +15,12 @@ jobs:
os: [ubuntu-20.04, macos-12, windows-latest]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go >=1.19
uses: actions/setup-go@v4
- name: Set up Go >=1.22
uses: actions/setup-go@v5
with:
go-version: '>=1.19.0'
go-version: '>=1.22.0'
id: go

- name: Get dependencies
Expand All @@ -42,14 +42,14 @@ jobs:

- name: Build ARMv8 binary
if: ${{ success() }}
run: go build -o ${{ matrix.os == 'windows-latest' && 'octyne-armv8.exe' || 'octyne-armv8' }} -ldflags="-s -w" -v .
run: go build -o ${{ matrix.os == 'windows-latest' && 'octyne-arm64.exe' || 'octyne-arm64' }} -ldflags="-s -w" -v .

- name: Build ARMv6 binary for Linux
if: ${{ success() && matrix.os == 'ubuntu-20.04' }}
run: GOARCH=arm GOARM=6 go build -o octyne-armv6 -ldflags="-s -w" -v .

- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ success() }}
with:
name: octyne-${{ matrix.os }}
Expand Down
35 changes: 16 additions & 19 deletions connector.go
Expand Up @@ -11,7 +11,6 @@ import (
"strings"
"sync"

"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"github.com/puzpuzpuz/xsync/v3"
"github.com/retrixe/octyne/auth"
Expand Down Expand Up @@ -70,7 +69,6 @@ type Ticket struct {
// Connector is used to create an HTTP API for external apps to talk with octyne.
type Connector struct {
auth.Authenticator
*mux.Router
*websocket.Upgrader
*Logger
Processes *xsync.MapOf[string, *ExposedProcess]
Expand Down Expand Up @@ -108,7 +106,6 @@ func InitializeConnector(config *Config) *Connector {
}
// Create the connector.
connector := &Connector{
Router: mux.NewRouter().StrictSlash(true),
Logger: &Logger{LoggingConfig: config.Logging, Zap: CreateZapLogger(config.Logging)},
Processes: xsync.NewMapOf[string, *ExposedProcess](),
Tickets: xsync.NewMapOf[string, Ticket](),
Expand Down Expand Up @@ -149,25 +146,25 @@ func InitializeConnector(config *Config) *Connector {
POST /server/{id}/decompress?path=path
*/

connector.Handle("/login", WrapEndpointWithCtx(connector, loginEndpoint))
connector.Handle("/logout", WrapEndpointWithCtx(connector, logoutEndpoint))
connector.Handle("/ott", WrapEndpointWithCtx(connector, ottEndpoint))
connector.Handle("/accounts", WrapEndpointWithCtx(connector, accountsEndpoint))
http.Handle("/login", WrapEndpointWithCtx(connector, loginEndpoint))
http.Handle("/logout", WrapEndpointWithCtx(connector, logoutEndpoint))
http.Handle("/ott", WrapEndpointWithCtx(connector, ottEndpoint))
http.Handle("/accounts", WrapEndpointWithCtx(connector, accountsEndpoint))

connector.HandleFunc("/", rootEndpoint)
connector.Handle("/config", WrapEndpointWithCtx(connector, configEndpoint))
connector.Handle("/config/reload", WrapEndpointWithCtx(connector, configReloadEndpoint))
connector.Handle("/servers", WrapEndpointWithCtx(connector, serversEndpoint))
connector.Handle("/server/{id}", WrapEndpointWithCtx(connector, serverEndpoint))
http.HandleFunc("/", rootEndpoint)
http.Handle("/config", WrapEndpointWithCtx(connector, configEndpoint))
http.Handle("/config/reload", WrapEndpointWithCtx(connector, configReloadEndpoint))
http.Handle("/servers", WrapEndpointWithCtx(connector, serversEndpoint))
http.Handle("/server/{id}", WrapEndpointWithCtx(connector, serverEndpoint))
connector.Upgrader.CheckOrigin = func(r *http.Request) bool { return true }
connector.Handle("/server/{id}/console", WrapEndpointWithCtx(connector, consoleEndpoint))
http.Handle("/server/{id}/console", WrapEndpointWithCtx(connector, consoleEndpoint))

connector.Handle("/server/{id}/files", WrapEndpointWithCtx(connector, filesEndpoint))
connector.Handle("/server/{id}/file", WrapEndpointWithCtx(connector, fileEndpoint))
connector.Handle("/server/{id}/folder", WrapEndpointWithCtx(connector, folderEndpoint))
connector.Handle("/server/{id}/compress", WrapEndpointWithCtx(connector, compressionEndpoint))
connector.Handle("/server/{id}/compress/v2", WrapEndpointWithCtx(connector, compressionEndpoint))
connector.Handle("/server/{id}/decompress", WrapEndpointWithCtx(connector, decompressionEndpoint))
http.Handle("/server/{id}/files", WrapEndpointWithCtx(connector, filesEndpoint))
http.Handle("/server/{id}/file", WrapEndpointWithCtx(connector, fileEndpoint))
http.Handle("/server/{id}/folder", WrapEndpointWithCtx(connector, folderEndpoint))
http.Handle("/server/{id}/compress", WrapEndpointWithCtx(connector, compressionEndpoint))
http.Handle("/server/{id}/compress/v2", WrapEndpointWithCtx(connector, compressionEndpoint))
http.Handle("/server/{id}/decompress", WrapEndpointWithCtx(connector, decompressionEndpoint))
return connector
}

Expand Down
11 changes: 5 additions & 6 deletions endpoints_files.go
Expand Up @@ -18,7 +18,6 @@ import (
"strings"
"time"

"github.com/gorilla/mux"
"github.com/puzpuzpuz/xsync/v3"
"github.com/retrixe/octyne/system"
)
Expand Down Expand Up @@ -48,7 +47,7 @@ func filesEndpoint(connector *Connector, w http.ResponseWriter, r *http.Request)
return
}
// Get the process being accessed.
id := mux.Vars(r)["id"]
id := r.PathValue("id")
process, err := connector.Processes.Load(id)
// In case the process doesn't exist.
if !err {
Expand Down Expand Up @@ -121,7 +120,7 @@ func fileEndpoint(connector *Connector, w http.ResponseWriter, r *http.Request)
return
}
// Get the process being accessed.
id := mux.Vars(r)["id"]
id := r.PathValue("id")
process, err := connector.Processes.Load(id)
// In case the process doesn't exist.
if !err {
Expand Down Expand Up @@ -340,7 +339,7 @@ func folderEndpoint(connector *Connector, w http.ResponseWriter, r *http.Request
return
}
// Get the process being accessed.
id := mux.Vars(r)["id"]
id := r.PathValue("id")
process, err := connector.Processes.Load(id)
// In case the process doesn't exist.
if !err {
Expand Down Expand Up @@ -389,7 +388,7 @@ func compressionEndpoint(connector *Connector, w http.ResponseWriter, r *http.Re
return
}
// Get the process being accessed.
id := mux.Vars(r)["id"]
id := r.PathValue("id")
process, exists := connector.Processes.Load(id)
// In case the process doesn't exist.
if !exists {
Expand Down Expand Up @@ -567,7 +566,7 @@ func decompressionEndpoint(connector *Connector, w http.ResponseWriter, r *http.
return
}
// Get the process being accessed.
id := mux.Vars(r)["id"]
id := r.PathValue("id")
process, err := connector.Processes.Load(id)
// In case the process doesn't exist.
if !err {
Expand Down
5 changes: 2 additions & 3 deletions endpoints_misc.go
Expand Up @@ -9,7 +9,6 @@ import (
"strings"
"time"

"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"github.com/retrixe/octyne/auth"
"github.com/retrixe/octyne/system"
Expand Down Expand Up @@ -159,7 +158,7 @@ func serverEndpoint(connector *Connector, w http.ResponseWriter, r *http.Request
return
}
// Get the process being accessed.
id := mux.Vars(r)["id"]
id := r.PathValue("id")
process, err := connector.Processes.Load(id)
// In case the process doesn't exist.
if !err {
Expand Down Expand Up @@ -269,7 +268,7 @@ func consoleEndpoint(connector *Connector, w http.ResponseWriter, r *http.Reques
token = ticket.Token
}
// Get the server being accessed.
id := mux.Vars(r)["id"]
id := r.PathValue("id")
process, exists := connector.Processes.Load(id)
// In case the server doesn't exist.
if !exists {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
@@ -1,11 +1,10 @@
module github.com/retrixe/octyne

go 1.18
go 1.22

require (
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4
github.com/gorilla/websocket v1.4.2
github.com/puzpuzpuz/xsync/v3 v3.0.2
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a
Expand Down
8 changes: 6 additions & 2 deletions go.sum
@@ -1,33 +1,37 @@
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
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/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/puzpuzpuz/xsync/v3 v3.0.2 h1:3yESHrRFYr6xzkz61LLkvNiPFXxJEAABanTQpKbAaew=
github.com/puzpuzpuz/xsync/v3 v3.0.2/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a h1:SJy1Pu0eH1C29XwJucQo73FrleVK6t4kYz4NVhp34Yw=
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a/go.mod h1:DFSS3NAGHthKo1gTlmEcSBiZrRJXi28rLNd/1udP1c8=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -102,7 +102,7 @@ func main() {
}),
handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS", "PATCH", "DELETE"}),
handlers.AllowedOrigins([]string{"*"}),
)(connector.Router)
)(http.DefaultServeMux)
server := &http.Server{
Addr: port,
Handler: handler,
Expand Down

0 comments on commit 37a2a66

Please sign in to comment.