Skip to content

Commit

Permalink
fix(launcher): Add workaround for login server issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cedws committed Nov 28, 2024
1 parent f76d1b2 commit 73d9e42
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/cedws/umbra-launcher
go 1.23.2

require (
github.com/cedws/w101-client-go v0.0.0-20241125233420-e29a3ba366fd
github.com/cedws/w101-proto-go v0.0.0-20241123173233-29fff1fc3bae
github.com/cedws/w101-client-go v0.0.0-20241127195155-593f54c07de7
github.com/cedws/w101-proto-go v0.0.0-20241127005008-4a3c16215c55
github.com/saferwall/pe v1.5.5
github.com/spf13/afero v1.11.0
go.mozilla.org/pkcs7 v0.9.0
Expand All @@ -16,6 +16,6 @@ require (
github.com/secDre4mer/pkcs7 v0.0.0-20240322103146-665324a4461d // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/cedws/w101-client-go v0.0.0-20241125233420-e29a3ba366fd h1:fJA6YRM2r5N01ijTE5yeXfOFGNy2TloWOCBPTAmPVmI=
github.com/cedws/w101-client-go v0.0.0-20241125233420-e29a3ba366fd/go.mod h1:LEEZPLzH2mdzndxQPSwg+7ho+Q1U+raLB6802UUvLzQ=
github.com/cedws/w101-proto-go v0.0.0-20241123173233-29fff1fc3bae h1:rCpDIzm/BK68zMKEaYCPzcme3e9YXR0PouHjsZ5VzEM=
github.com/cedws/w101-proto-go v0.0.0-20241123173233-29fff1fc3bae/go.mod h1:txaQ4U+DqZHIFvn2q7DLiT1kEtKk6VGy8WmFd/l1lbs=
github.com/cedws/w101-client-go v0.0.0-20241127195155-593f54c07de7 h1:3IrkrMR5v3IqcIvr6m5rApoChpoo2ef/V7RYYStLUzI=
github.com/cedws/w101-client-go v0.0.0-20241127195155-593f54c07de7/go.mod h1:LEEZPLzH2mdzndxQPSwg+7ho+Q1U+raLB6802UUvLzQ=
github.com/cedws/w101-proto-go v0.0.0-20241127005008-4a3c16215c55 h1:ZuATZJIzJ87rQwUKOgexzT9bx8mJDPCx8G4D81REKgc=
github.com/cedws/w101-proto-go v0.0.0-20241127005008-4a3c16215c55/go.mod h1:xRa+HlP7lK7eSl/0MJsv1Fkm1gD8RuEzllQK/dOt2WE=
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/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ=
Expand Down Expand Up @@ -37,8 +37,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
23 changes: 19 additions & 4 deletions internal/umbra/umbra.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (
fileTypeDynamicWAD = 5
)

const loginServerRetries = 10

var (
errTimeoutAuthenRsp = fmt.Errorf("timed out waiting for authen response")
errTimeoutFileList = fmt.Errorf("timed out waiting for latest file list")
Expand Down Expand Up @@ -313,15 +315,28 @@ func (p *patchClient) requestCK2Token(ctx context.Context, params LaunchParams)
authenRspCh := make(chan login.UserAuthenRsp)

r := proto.NewMessageRouter()
login.RegisterLoginService(r, &loginHandler{authenRspCh: authenRspCh})
login.RegisterLoginService(&r, &loginHandler{authenRspCh: authenRspCh})

ctx, cancel := context.WithTimeoutCause(ctx, 10*time.Second, errTimeoutAuthenRsp)
defer cancel()

protoClient, err := proto.Dial(ctx, params.LoginServerAddr, r)
var (
protoClient *proto.Client
err error
)

// Temporary workaround for KI login server issues
// For some reason they're dropping connections every so often
for range loginServerRetries {
protoClient, err = proto.Dial(ctx, params.LoginServerAddr, &r)
if err == nil {
break
}
}
if err != nil {
return 0, "", err
}

defer protoClient.Close()

slog.Info("Connected to login server", "server", params.LoginServerAddr)
Expand Down Expand Up @@ -468,12 +483,12 @@ func (p *patchClient) latestFileList(ctx context.Context) (*patch.LatestFileList
fileListCh := make(chan patch.LatestFileListV2)

r := proto.NewMessageRouter()
patch.RegisterPatchService(r, &patchHandler{fileListCh: fileListCh})
patch.RegisterPatchService(&r, &patchHandler{fileListCh: fileListCh})

ctx, cancel := context.WithTimeoutCause(ctx, 10*time.Second, errTimeoutFileList)
defer cancel()

protoClient, err := proto.Dial(ctx, p.LaunchParams.PatchServerAddr, r)
protoClient, err := proto.Dial(ctx, p.LaunchParams.PatchServerAddr, &r)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 73d9e42

Please sign in to comment.