-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dockerfile and export simple api to send/receive messages #92
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git | ||
bin/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
RPC API | ||
====== | ||
Start service with configuration file that enables API: | ||
|
||
``` | ||
./bin/status-term-client -node-config ./_assets/api.conf -no-ui --keyhex=0x123 | ||
``` | ||
|
||
Configuration example: | ||
|
||
```json | ||
{ | ||
"HTTPHost": "localhost", | ||
"HTTPPort": 8777, | ||
"HTTPEnabled": true, | ||
"APIModules": "ssm" | ||
} | ||
``` | ||
|
||
Add contact | ||
=========== | ||
|
||
``` | ||
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"ssm_addContact","params":[{"name": "222"}],"id":1}' http://localhost:8777 | ||
``` | ||
|
||
|
||
Returns error if failed otherwise null. | ||
|
||
Send to contact | ||
=============== | ||
|
||
``` | ||
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"ssm_sendToContact","params":[{"name": "222"}, "plain text"],"id":1}' http://localhost:8777 | ||
``` | ||
|
||
Returns error if failed otherwise null. | ||
|
||
Read all (including ours) from contact | ||
====================================== | ||
|
||
|
||
To read all messages use 0 as offset: | ||
|
||
``` | ||
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"ssm_readContactMessages","params":[{"name": "222"}, 0],"id":1}' http://localhost:8777 | ||
``` | ||
|
||
To read new messages use last known offset: | ||
|
||
``` | ||
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"ssm_readContactMessages","params":[{"name": "222"}, 2],"id":1}' http://localhost:8777 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Build status-go in a Go builder container | ||
FROM golang:1.12.5-alpine as builder | ||
|
||
RUN apk add --no-cache make gcc musl-dev linux-headers | ||
|
||
RUN mkdir -p /go/src/github.com/status-im/status-console-client | ||
ADD . /go/src/github.com/status-im/status-console-client | ||
WORKDIR /go/src/github.com/status-im/status-console-client | ||
RUN make build | ||
|
||
# Copy the binary to the second image | ||
FROM alpine:latest | ||
|
||
LABEL maintainer="support@status.im" | ||
LABEL source="https://github.com/status-im/status-console-client" | ||
|
||
COPY --from=builder /go/src/github.com/status-im/status-console-client/bin/status-term-client /usr/local/bin/ | ||
|
||
# 30304 is used for Discovery v5 | ||
EXPOSE 8080 8545 30303 30303/udp 30304/udp | ||
|
||
ENTRYPOINT ["/usr/local/bin/status-term-client", "-no-ui"] | ||
CMD ["--help"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"HTTPHost": "localhost", | ||
"HTTPPort": 8777, | ||
"HTTPEnabled": true, | ||
"APIModules": "ssm" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,7 +141,8 @@ func (m *Messenger) Join(ctx context.Context, c Contact) error { | |
} | ||
|
||
opts := protocol.DefaultRequestOptions() | ||
if err := m.Request(ctx, c, opts); err != nil { | ||
// NOTE(dshulyak) join ctx shouldn't have an impact on history timeout. | ||
if err := m.Request(context.Background(), c, opts); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should remove sending a request when joining and make it a separate action? It wouldn't be this PR change though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think ideally it should be managed in background, so that we can do multiple attempts without blocking an API the same when messenger is started |
||
return err | ||
} | ||
return m.db.UpdateHistories([]History{{Contact: c, Synced: opts.To}}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package transport | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSelectAndAddNoMailservers(t *testing.T) { | ||
svc := &WhisperServiceTransport{} | ||
rst, err := svc.selectAndAddMailServer() | ||
require.Empty(t, rst) | ||
require.EqualError(t, ErrNoMailservers, err.Error()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add a
.dockerignore
and ignore.git
and other unnecessary dirs.