Skip to content
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

fix(server): random panics on close message handle. #71

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Immortal
<p align="center">
<img alt="immortal" src="./images/immo.svg" width="150" height="150" />
</p>

<h3 align="center">
Immortal
</h3>

<br/>


The Immortal is a [Nostr](https://nostr.com) relay implementation written in Golang.

Expand All @@ -15,7 +24,7 @@ Updates and changes or community discussions can be followed on the Github issue
## Contribution

All kind of contributions are welcome!
Make sure you read the [Contribution guides](./CONTRIBUTING.md) before any contribution.
Make sure you read the [Contribution guides](./CONTRIBUTING.md) before any code contribution.

## Donation

Expand All @@ -27,7 +36,11 @@ Donations and financial support of the development process is possible using Bit
bc1qxd3p6a46uzae86elteha7tygcz7f56mvvlznza
```

**lightning**: ```TODO```
**lightning**:

```
[email protected]
```

## License

Expand Down
11 changes: 0 additions & 11 deletions documents/NIPs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@
The Immortal follows [NIPs](https://github.com/nostr-protocol/nips) and tries to implement itself as close as possible to this standards.

- [X] **NIP-01**: Basic Protocol Flow Description
- [ ] **NIP-02**: Follow List
- [ ] **NIP-03**: OpenTimestamps Attestations for Events
- [ ] **NIP-09**: Event Deletion Request
- [X] **NIP-11**: Relay Information Document
- [ ] **NIP-13**: Proof of Work
- [ ] **NIP-15**: Nostr Marketplace (for resilient marketplaces)
- [ ] **NIP-17**: Private Direct Messages
- [ ] **NIP-18**: Reposts
- [ ] **NIP-23**: Long-form Content
- [ ] **NIP-25**: Reactions
- [ ] **NIP-26**: Delegated Event Signing
- [ ] **NIP-28**: Public Chat
- [ ] **NIP-29**: Relay-based Groups
- [ ] **NIP-32**: Labeling
- [ ] **NIP-40**: Expiration Timestamp
- [ ] **NIP-42**: Authentication of Clients to Relays
- [ ] **NIP-50**: Search Capability
Expand Down
9 changes: 9 additions & 0 deletions images/immo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/immortal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/immortal_wide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/immortal_wide2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ devtools:
@echo "Installing devtools"
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install mvdan.cc/gofumpt@latest
go install github.com/volatiletech/sqlboiler/v4@latest
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest

### Testing
unit-test:
Expand Down
4 changes: 2 additions & 2 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Metrics struct {
MessagesTotal prometheus.Counter
Subscriptions prometheus.Gauge
Connections prometheus.Gauge
EventLaency prometheus.Histogram
EventLatency prometheus.Histogram
RequestLatency prometheus.Histogram
}

Expand Down Expand Up @@ -57,7 +57,7 @@ func New() *Metrics {
MessagesTotal: msgT,
Subscriptions: subs,
RequestsTotal: reqsT,
EventLaency: eventL,
EventLatency: eventL,
RequestLatency: reqL,
}
}
6 changes: 3 additions & 3 deletions server/websocket/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (s *Server) handleReq(conn *websocket.Conn, m message.Message) {
func (s *Server) handleEvent(conn *websocket.Conn, m message.Message) {
s.mu.Lock()
defer s.mu.Unlock()
defer measureLatency(s.metrics.EventLaency)()
defer measureLatency(s.metrics.EventLatency)()

status := success
defer func() {
Expand Down Expand Up @@ -320,8 +320,8 @@ func (s *Server) handleEvent(conn *websocket.Conn, m message.Message) {

// handleClose handles new incoming CLOSE messages from client.
func (s *Server) handleClose(conn *websocket.Conn, m message.Message) {
s.mu.RLock()
defer s.mu.RUnlock()
s.mu.Lock()
defer s.mu.Unlock()

msg, ok := m.(*message.Close)
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "fmt"
var (
major = 0
minor = 0
patch = 4
patch = 5
meta = "beta"
)

Expand Down