Skip to content

Commit

Permalink
finish doc about metrics and code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaojianli committed Jan 14, 2025
1 parent 4d416ff commit d195cec
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 61 deletions.
3 changes: 2 additions & 1 deletion biz/handler/announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/PBH-BTN/trunker/utils/http"
"github.com/cloudwego/hertz/pkg/app"
"github.com/thinkeridea/go-extend/exstrings"
hertz "github.com/cloudwego/hertz/pkg/common/utils"
)

func Announce(ctx context.Context, c *app.RequestContext) {
Expand Down Expand Up @@ -48,7 +49,7 @@ func Announce(ctx context.Context, c *app.RequestContext) {
Complete: scrape.Complete,
})
} else {
resp := map[string]any{
resp := hertz.H{
"interval": config.AppConfig.Tracker.TTL + int64(rand.Intn(201)-100),
"external ip": req.ClientIP.String(),
"incomplete": scrape.Incomplete,
Expand Down
18 changes: 0 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/*
* Copyright 2022 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Code generated by hertz generator.

package main

import (
Expand Down
21 changes: 13 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Introduction

A high-performance BitTorrent Tracker implemented in Go. Using [Hertz](https://github.com/cloudwego/hertz) from cloudwego.
A high-performance BitTorrent Tracker implemented in Go. Using [Hertz](https://github.com/cloudwego/hertz) from cloudwego, with observability.

This tracker is hosted as https://btn-prod.ghostchu-services.top/announce

Expand All @@ -26,13 +26,13 @@ docker pull gaojianli2333/trunker:latest
```
## Features

- [x] BEP-0003
- [x] BEP-0007
- [x] BEP-0023
- [x] BEP-0024
- [x] BEP-0031
- [x] BEP-0048
- [X] LT-Extension(complete,incomplete)
- [x] [BEP-0003](https://www.bittorrent.org/beps/bep_0003.html)
- [x] [BEP-0007](https://www.bittorrent.org/beps/bep_0007.html) (IPv6 Tracker Extension)
- [x] [BEP-0023](https://www.bittorrent.org/beps/bep_0023.html) (Compact Peer Lists)
- [x] [BEP-0024](https://www.bittorrent.org/beps/bep_0024.html) (External IP)
- [x] [BEP-0031](https://www.bittorrent.org/beps/bep_0031.html) (Failure Retry Extension)
- [x] [BEP-0048](https://www.bittorrent.org/beps/bep_0048.html) (Scrape)
- [X] LT-Extension (complete,incomplete)
- [x] Full-Memory Mode
- [x] Load from Persist
- [ ] MySQL Mode
Expand Down Expand Up @@ -85,6 +85,11 @@ You can ban some torrent or peer by using the following endpoints.
| GET | `/admin/info_hash/:infoHash/peers` | Get all peers of a info_hash. **The response may be very large** |
| DELETE | `/admin/info_hash/:infoHash` | Delete a info_hash |

## Metrics
Currently trunker is serving a prometheus handler at `:9091` by default. With 2 paths:
- `/metrics` Providing metrics about http request, including latency and QPS.
- `/pprof` Providing golang runtime pprof info.

## Benchmark

CPU: 4 Cores ARM64 Oracle Cloud
Expand Down
18 changes: 0 additions & 18 deletions router.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/*
* Copyright 2022 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Code generated by hertz generator.

package main

import (
Expand Down
16 changes: 0 additions & 16 deletions service/database/init.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
* Copyright 2022 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package database

import (
Expand Down

0 comments on commit d195cec

Please sign in to comment.