Skip to content

Commit

Permalink
Workaround for #23
Browse files Browse the repository at this point in the history
  • Loading branch information
TPolzer committed Nov 25, 2017
1 parent 9c136b3 commit 1771cf1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 37 deletions.
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,18 @@ And at (client) runtime:
- DejaVu Sans and Symbola for proper display

The setup currently involves:
- in the top level directory:
```
$ export GOPATH="`pwd`"
$ go get github.com/golang/protobuf/proto github.com/rthornton128/goncurses golang.org/x/crypto/nacl/secretbox golang.org/x/crypto/scrypt
$ go build server
```
- in the src/client subdirectory
```
$ cmake .
$ cmake src/client
$ make -j4
```

To use it:
- put your credentials into credentials.json
- adjust the server url in config.json
- put a secret passphrase in config.json for both server and client (the whole file can be shared between both)
- possibly adjust server name / port in config.json
- start the server
- start the client
- put a secret passphrase in config.json
- possibly adjust server name/api path/port in config.json
- start ./server
- start ./client (cannot be started before the server, but will try to reconnect if server is restarted/lost/etc.)
5 changes: 4 additions & 1 deletion config.README
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ Both server and client expect a file 'config.json' in their working directory.
Its entries are:

baseurl: [server], string, required
The server looks at `baseurl`/api/*, has to end with a slash.
apipath: [server], string optional default "api/v3/"
The server looks at `baseurl``apipath`, both have to end with a slash.
The split does not matter in principle, but makes this backwards compatible
with older Carnifex binaries.

simulate: [server], bool, default false
If true, the server will simulate the the contest events relative to server
Expand Down
19 changes: 0 additions & 19 deletions src/client/config.json

This file was deleted.

14 changes: 7 additions & 7 deletions src/score/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ func NewJudgeClient(judge *url.URL, username string, password string, insecure b
username: username,
password: password,
}
client.urls[JUDGINGS], _ = judge.Parse("./api/judgings")
client.urls[SUBMISSIONS], _ = judge.Parse("./api/submissions")
client.urls[CONTESTS], _ = judge.Parse("./api/contests")
client.urls[CONFIG], _ = judge.Parse("./api/config")
client.urls[TEAMS], _ = judge.Parse("./api/teams?public=true")
client.urls[PROBLEMS], _ = judge.Parse("./api/problems")
client.urls[CATEGORIES], _ = judge.Parse("./api/categories?public=true")
client.urls[JUDGINGS], _ = judge.Parse("./judgings")
client.urls[SUBMISSIONS], _ = judge.Parse("./submissions")
client.urls[CONTESTS], _ = judge.Parse("./contests")
client.urls[CONFIG], _ = judge.Parse("./config")
client.urls[TEAMS], _ = judge.Parse("./teams?public=true")
client.urls[PROBLEMS], _ = judge.Parse("./problems")
client.urls[CATEGORIES], _ = judge.Parse("./categories?public=true")
return client
}

Expand Down
11 changes: 10 additions & 1 deletion src/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var cursesLock *sync.Mutex

type Config struct {
BaseUrl string
ApiPath *string
Simulate bool
SimulationSpeed float64
SharedSecret *string
Expand Down Expand Up @@ -132,14 +133,22 @@ func main() {
if(config.SharedSecret == nil) {
log.Fatal("no sharedsecret provided in config")
}
if(config.ApiPath == nil) {
ApiPath := "api/v3/"
config.ApiPath = &ApiPath
}

judgeUrl, err := url.Parse(config.BaseUrl)
if(err != nil) {
log.Fatal("invalid baseURL")
}
judgeUrl, err = judgeUrl.Parse(*config.ApiPath)
if(err != nil) {
log.Fatal("invalid ApiPath")
}

if(config.DumpData) {
dir := filepath.Join("./", judgeUrl.Path, "api")
dir := filepath.Join("./", judgeUrl.Path, *config.ApiPath)
err := os.MkdirAll(dir, 0777)
if(err != nil) {
log.Fatalf("could not create path %s", dir)
Expand Down

0 comments on commit 1771cf1

Please sign in to comment.