mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-08 06:01:55 -07:00
Rename to MoChi
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
github: [ jzelinskie ]
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
labels:
|
|
||||||
- "component/dependencies"
|
|
||||||
|
|
||||||
- package-ecosystem: "gomod"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
labels:
|
|
||||||
- "component/dependencies"
|
|
||||||
|
|
||||||
- package-ecosystem: "docker"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
labels:
|
|
||||||
- "component/dependencies"
|
|
||||||
@@ -56,12 +56,12 @@ jobs:
|
|||||||
go-version: ^1.15
|
go-version: ^1.15
|
||||||
- name: End-to-End Test
|
- name: End-to-End Test
|
||||||
run: |
|
run: |
|
||||||
go install --tags e2e ./cmd/chihaya
|
go install --tags e2e ./cmd/mochi
|
||||||
cat ./dist/example_config.yaml
|
cat ./dist/example_config.yaml
|
||||||
chihaya --config=./dist/example_config.yaml --debug &
|
mochi --config=./dist/example_config.yaml --debug &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 2
|
sleep 2
|
||||||
chihaya e2e --debug
|
mochi e2e --debug
|
||||||
kill $pid
|
kill $pid
|
||||||
|
|
||||||
e2e-redis:
|
e2e-redis:
|
||||||
@@ -83,33 +83,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
curl -LO https://github.com/jzelinskie/faq/releases/download/0.0.6/faq-linux-amd64
|
curl -LO https://github.com/jzelinskie/faq/releases/download/0.0.6/faq-linux-amd64
|
||||||
chmod +x faq-linux-amd64
|
chmod +x faq-linux-amd64
|
||||||
./faq-linux-amd64 '.chihaya.storage = {"config":{"gc_interval":"3m","peer_lifetime":"31m","prometheus_reporting_interval":"1s","redis_broker":"redis://127.0.0.1:6379/0","redis_connect_timeout":"15s","redis_read_timeout":"15s","redis_write_timeout":"15s"},"name":"redis"}' ./dist/example_config.yaml > ./dist/example_redis_config.yaml
|
./faq-linux-amd64 '.mochi.storage = {"config":{"gc_interval":"3m","peer_lifetime":"31m","prometheus_reporting_interval":"1s","redis_broker":"redis://127.0.0.1:6379/0","redis_connect_timeout":"15s","redis_read_timeout":"15s","redis_write_timeout":"15s"},"name":"redis"}' ./dist/example_config.yaml > ./dist/example_redis_config.yaml
|
||||||
cat ./dist/example_redis_config.yaml
|
cat ./dist/example_redis_config.yaml
|
||||||
- name: End-to-End Test
|
- name: End-to-End Test
|
||||||
run: |
|
run: |
|
||||||
go install --tags e2e ./cmd/chihaya
|
go install --tags e2e ./cmd/mochi
|
||||||
chihaya --config=./dist/example_redis_config.yaml --debug &
|
mochi --config=./dist/example_redis_config.yaml --debug &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 2
|
sleep 2
|
||||||
chihaya e2e --debug
|
mochi e2e --debug
|
||||||
kill $pid
|
kill $pid
|
||||||
|
|
||||||
dist:
|
|
||||||
name: Helm Template
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Install Helm
|
|
||||||
uses: engineerd/configurator@v0.0.5
|
|
||||||
with:
|
|
||||||
name: helm
|
|
||||||
pathInArchive: linux-amd64/helm
|
|
||||||
fromGitHubReleases: true
|
|
||||||
repo: helm/helm
|
|
||||||
version: ^v3
|
|
||||||
urlTemplate: https://get.helm.sh/helm-{{version}}-linux-amd64.tar.gz
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Helm Template
|
|
||||||
working-directory: ./dist/helm/chihaya
|
|
||||||
run: helm template . --debug
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
/test_data
|
/test_data
|
||||||
|
/.idea
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
## Discussion
|
|
||||||
|
|
||||||
Long-term discussion and bug reports are maintained via [GitHub Issues]. Code review is done via [GitHub Pull Requests].
|
|
||||||
Real-time discussion is done via [freenode IRC].
|
|
||||||
|
|
||||||
[GitHub Issues]: https://github.com/chihaya/chihaya/issues
|
|
||||||
|
|
||||||
[GitHub Pull Requests]: https://github.com/chihaya/chihaya/pulls
|
|
||||||
|
|
||||||
[freenode IRC]: http://webchat.freenode.net/?channels=chihaya
|
|
||||||
|
|
||||||
## Pull Request Procedure
|
|
||||||
|
|
||||||
If you're looking to contribute, search the GitHub for issues labeled "low-hanging fruit". You can also hop into IRC and
|
|
||||||
ask a developer who's online for their opinion.
|
|
||||||
|
|
||||||
Small, self-describing fixes are perfectly fine to submit without discussion. However, please do not submit a massive
|
|
||||||
Pull Request without prior communication. Large, unannounced changes usually lead to confusion and time wasted for
|
|
||||||
everyone. If you were planning to write a large change, post an issue on GitHub first and discuss it.
|
|
||||||
|
|
||||||
Pull Requests will be treated as "review requests", and we will give feedback we expect to see corrected on style and
|
|
||||||
substance before merging. Changes contributed via Pull Request should focus on a single issue at a time. We will not
|
|
||||||
accept pull-requests that try to "sneak" unrelated changes in.
|
|
||||||
|
|
||||||
The average contribution flow is as follows:
|
|
||||||
|
|
||||||
- Determine what to work on via creating and issue or finding an issue you want to solve.
|
|
||||||
- Create a topic branch from where you want to base your work. This is usually `master`.
|
|
||||||
- Make commits of logical units.
|
|
||||||
- Make sure your commit messages are in the proper format
|
|
||||||
- Push your changes to a topic branch in your fork of the repository.
|
|
||||||
- Submit a pull request.
|
|
||||||
- Your PR will be reviewed and merged by one of the maintainers.
|
|
||||||
- You may be asked to make changes and [rebase] your commits.
|
|
||||||
|
|
||||||
[rebase]: https://git-scm.com/book/en/v2/Git-Branching-Rebasin://git-scm.com/book/en/v2/Git-Branching-Rebasing
|
|
||||||
|
|
||||||
## Style
|
|
||||||
|
|
||||||
Any new files should include the license header found at the top of every source file.
|
|
||||||
|
|
||||||
### Go
|
|
||||||
|
|
||||||
The project follows idiomatic [Go conventions] for style. If you're just starting out writing Go, you can check out
|
|
||||||
this [meta-package] that documents style idiomatic style decisions you will find in open source Go code. All files
|
|
||||||
should have `gofmt` executed on them and code should strive to have full coverage of static analysis tools like [govet]
|
|
||||||
and [golint].
|
|
||||||
|
|
||||||
[Go conventions]: https://github.com/golang/go/wiki/CodeReviewComments
|
|
||||||
|
|
||||||
[meta-package]: https://github.com/jzelinskie/conventions
|
|
||||||
|
|
||||||
[govet]: https://golang.org/cmd/vet
|
|
||||||
|
|
||||||
[golint]: https://github.com/golang/lint
|
|
||||||
|
|
||||||
### Commit Messages
|
|
||||||
|
|
||||||
We follow a rough convention for commit messages that is designed to answer two questions: what changed and why. The
|
|
||||||
subject line should feature the what and the body of the commit should describe the why.
|
|
||||||
|
|
||||||
```
|
|
||||||
scripts: add the test-cluster command
|
|
||||||
|
|
||||||
this uses tmux to setup a test cluster that you can easily kill and
|
|
||||||
start for debugging.
|
|
||||||
|
|
||||||
Fixes #38
|
|
||||||
```
|
|
||||||
|
|
||||||
The format can be described more formally as follows:
|
|
||||||
|
|
||||||
```
|
|
||||||
<subsystem>: <what changed>
|
|
||||||
<BLANK LINE>
|
|
||||||
<why this change was made>
|
|
||||||
<BLANK LINE>
|
|
||||||
<footer>
|
|
||||||
```
|
|
||||||
|
|
||||||
The first line is the subject and should be no longer than 70 characters, the second line is always blank, and other
|
|
||||||
lines should be wrapped at 80 characters. This allows the message to be easier to read on GitHub as well as in various
|
|
||||||
git tools.
|
|
||||||
+7
-7
@@ -5,22 +5,22 @@ LABEL maintainer "Jimmy Zelinskie <jimmyzelinskie+git@gmail.com>"
|
|||||||
RUN apk add --no-cache curl git
|
RUN apk add --no-cache curl git
|
||||||
|
|
||||||
# Copy our source code into the container.
|
# Copy our source code into the container.
|
||||||
WORKDIR /go/src/github.com/chihaya/chihaya
|
WORKDIR /go/src/github.com/sot-tech/mochi
|
||||||
COPY . /go/src/github.com/chihaya/chihaya
|
COPY . /go/src/github.com/sot-tech/mochi
|
||||||
|
|
||||||
# Install our golang dependencies and compile our binary.
|
# Install our golang dependencies and compile our binary.
|
||||||
RUN CGO_ENABLED=0 go install ./cmd/chihaya
|
RUN CGO_ENABLED=0 go install ./cmd/mochi
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
COPY --from=build-env /go/bin/chihaya /chihaya
|
COPY --from=build-env /go/bin/mochi /mochi
|
||||||
|
|
||||||
RUN adduser -D chihaya
|
RUN adduser -D mochi
|
||||||
|
|
||||||
# Expose a docker interface to our binary.
|
# Expose a docker interface to our binary.
|
||||||
EXPOSE 6880 6969
|
EXPOSE 6880 6969
|
||||||
|
|
||||||
# Drop root privileges
|
# Drop root privileges
|
||||||
USER chihaya
|
USER mochi
|
||||||
|
|
||||||
ENTRYPOINT ["/chihaya"]
|
ENTRYPOINT ["/mochi"]
|
||||||
|
|||||||
@@ -22,3 +22,7 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
Modified Chihaya (MoChi) licensed under the same licence as original Chihaya by SOT-TECH.
|
||||||
|
Copyright (c) 2021, SOT-TECH
|
||||||
|
Some rights reserved.
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
Jimmy Zelinskie <jimmyzelinskie@gmail.com> (@jzelinskie) pkg:*
|
Jimmy Zelinskie <jimmyzelinskie@gmail.com> (@jzelinskie) pkg:*
|
||||||
Justin Li <jli@j-li.net> (@pushrax) pkg:*
|
Justin Li <jli@j-li.net> (@pushrax) pkg:*
|
||||||
Leo Balduf <balduf@hm.edu> (@mrd0ll4r) pkg:*
|
Leo Balduf <balduf@hm.edu> (@mrd0ll4r) pkg:*
|
||||||
|
SOT-TECH <service@sot-te.ch> (@sot-tech) pkg:*
|
||||||
@@ -1,112 +1,24 @@
|
|||||||
# Chihaya
|
# Modified Chihaya (MoChi)
|
||||||
|
|
||||||
[](https://github.com/chihaya/chihaya/actions)
|
[](https://opensource.org/licenses/BSD-2-Clause)
|
||||||
[](https://quay.io/repository/jzelinskie/chihaya)
|
|
||||||
[](https://godoc.org/github.com/chihaya/chihaya)
|
|
||||||
[](https://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29)
|
|
||||||
[](https://web.libera.chat/#chihaya)
|
|
||||||
|
|
||||||
Chihaya is an open source [BitTorrent tracker] written in [Go].
|
Modified version of [Chihaya](https://github.com/chihaya/chihaya),
|
||||||
|
an open source BitTorrent tracker written in Go.
|
||||||
|
|
||||||
Differentiating features include:
|
## Differences from the original project
|
||||||
|
|
||||||
- HTTP and UDP protocols
|
* Support BittorrentV2 hashes (SHA-256 and _hybrid_ SHA-256-to-160 [BEP52](https://www.bittorrent.org/beps/bep_0052.html), tested with qBittorrent);
|
||||||
- IPv4 and IPv6 support
|
* Support storage in middleware modules to persist useful data;
|
||||||
- Pre/Post middleware hooks
|
* Metrics can be turned off (not enabled till it really needed).
|
||||||
- [YAML] configuration
|
|
||||||
- Metrics via [Prometheus]
|
|
||||||
- High Availability via [Redis]
|
|
||||||
- Kubernetes deployment via [Helm]
|
|
||||||
|
|
||||||
**Note:** The master branch may be in an unstable or even broken state during development. Please use [releases] instead
|
## Main goal
|
||||||
of the master branch in order to get stable binaries.
|
The main goal of made modifications is to create semi-private tracker like [Hefur](https://github.com/sot-tech/hefur)
|
||||||
|
but with cluster support (allowed torrents limited by pre-existent `list` middleware and another `directory` middleware to limit registered torrents).
|
||||||
|
|
||||||
[releases]: https://github.com/chihaya/chihaya/releases
|
## Notice
|
||||||
|
Modifications made with particular purpose, so if you need _pure_ tracker,
|
||||||
|
with guaranteed stability, please, use the [original project](https://github.com/chihaya/chihaya).
|
||||||
|
|
||||||
[BitTorrent tracker]: https://en.wikipedia.org/wiki/BitTorrent_tracker
|
Developer(s) of this project (MoChi) do not declare themselves as authors of original
|
||||||
|
project (Chihaya) and do not claim any other rights of original project.
|
||||||
|
|
||||||
[Go]: https://golang.org
|
|
||||||
|
|
||||||
[YAML]: https://yaml.org
|
|
||||||
|
|
||||||
[Prometheus]: https://prometheus.io
|
|
||||||
|
|
||||||
[Redis]: https://redis.io
|
|
||||||
|
|
||||||
[Helm]: https://helm.sh
|
|
||||||
|
|
||||||
## Why Chihaya?
|
|
||||||
|
|
||||||
Chihaya is built for developers looking to integrate BitTorrent into a preexisting production environment. Chihaya's
|
|
||||||
pluggable architecture and middleware framework offers a simple and flexible integration point that abstracts the
|
|
||||||
BitTorrent tracker protocols. The most common use case for Chihaya is enabling peer-to-peer cloud software deployments.
|
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
### Contributing
|
|
||||||
|
|
||||||
Long-term discussion and bug reports are maintained via [GitHub Issues]. Code review is done via [GitHub Pull Requests].
|
|
||||||
Real-time discussion is done via [freenode IRC].
|
|
||||||
|
|
||||||
For more information read [CONTRIBUTING.md].
|
|
||||||
|
|
||||||
[GitHub Issues]: https://github.com/chihaya/chihaya/issues
|
|
||||||
|
|
||||||
[GitHub Pull Requests]: https://github.com/chihaya/chihaya/pulls
|
|
||||||
|
|
||||||
[freenode IRC]: http://webchat.freenode.net/?channels=chihaya
|
|
||||||
|
|
||||||
[CONTRIBUTING.md]: https://github.com/chihaya/chihaya/blob/master/CONTRIBUTING.md
|
|
||||||
|
|
||||||
### Getting Started
|
|
||||||
|
|
||||||
#### Building from HEAD
|
|
||||||
|
|
||||||
In order to compile the project, the [latest stable version of Go] and knowledge of a [working Go environment] are
|
|
||||||
required.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ git clone git@github.com:chihaya/chihaya.git
|
|
||||||
$ cd chihaya
|
|
||||||
$ go build ./cmd/chihaya
|
|
||||||
$ ./chihaya --help
|
|
||||||
```
|
|
||||||
|
|
||||||
[latest stable version of Go]: https://golang.org/dl
|
|
||||||
|
|
||||||
[working Go environment]: https://golang.org/doc/code.html
|
|
||||||
|
|
||||||
#### Docker
|
|
||||||
|
|
||||||
Docker containers are available for [HEAD] and [stable] releases.
|
|
||||||
|
|
||||||
[HEAD]: https://quay.io/jzelinskie/chihaya-git
|
|
||||||
|
|
||||||
[stable]: https://quay.io/jzelinskie/chihaya
|
|
||||||
|
|
||||||
#### Testing
|
|
||||||
|
|
||||||
The following will run all tests and benchmarks. Removing `-bench` will just run unit tests.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ go test -bench $(go list ./...)
|
|
||||||
```
|
|
||||||
|
|
||||||
The Chihaya executable contains a command to end-to-end test a BitTorrent tracker. See
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ chihaya --help
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
Configuration of Chihaya is done via one YAML configuration file. The `dist/` directory contains an example
|
|
||||||
configuration file. Files and directories under `docs/` contain detailed information about configuring middleware,
|
|
||||||
storage implementations, architecture etc.
|
|
||||||
|
|
||||||
## Related projects
|
|
||||||
|
|
||||||
- [BitTorrent.org](https://github.com/bittorrent/bittorrent.org): a static website containing the BitTorrent spec and
|
|
||||||
all BEPs
|
|
||||||
- [OpenTracker](http://erdgeist.org/arts/software/opentracker): a popular BitTorrent tracker written in C
|
|
||||||
- [Ocelot](https://github.com/WhatCD/Ocelot): a private BitTorrent tracker written in C++
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Params is used to fetch (optional) request parameters from an Announce.
|
// Params is used to fetch (optional) request parameters from an Announce.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package bittorrent
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrInvalidIP indicates an invalid IP for an Announce.
|
// ErrInvalidIP indicates an invalid IP for an Announce.
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ import (
|
|||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/frontend/http"
|
"github.com/sot-tech/mochi/frontend/http"
|
||||||
"github.com/chihaya/chihaya/frontend/udp"
|
"github.com/sot-tech/mochi/frontend/udp"
|
||||||
"github.com/chihaya/chihaya/middleware"
|
"github.com/sot-tech/mochi/middleware"
|
||||||
|
|
||||||
// Imports to register middleware drivers.
|
// Imports to register middleware drivers.
|
||||||
_ "github.com/chihaya/chihaya/middleware/clientapproval"
|
_ "github.com/sot-tech/mochi/middleware/clientapproval"
|
||||||
_ "github.com/chihaya/chihaya/middleware/jwt"
|
_ "github.com/sot-tech/mochi/middleware/jwt"
|
||||||
_ "github.com/chihaya/chihaya/middleware/torrentapproval"
|
_ "github.com/sot-tech/mochi/middleware/torrentapproval"
|
||||||
_ "github.com/chihaya/chihaya/middleware/varinterval"
|
_ "github.com/sot-tech/mochi/middleware/varinterval"
|
||||||
|
|
||||||
// Imports to register storage drivers.
|
// Imports to register storage drivers.
|
||||||
_ "github.com/chihaya/chihaya/storage/memory"
|
_ "github.com/sot-tech/mochi/storage/memory"
|
||||||
_ "github.com/chihaya/chihaya/storage/redis"
|
_ "github.com/sot-tech/mochi/storage/redis"
|
||||||
)
|
)
|
||||||
|
|
||||||
type storageConfig struct {
|
type storageConfig struct {
|
||||||
@@ -26,7 +26,7 @@ type storageConfig struct {
|
|||||||
Config interface{} `yaml:"config"`
|
Config interface{} `yaml:"config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config represents the configuration used for executing Chihaya.
|
// Config represents the configuration used for executing Conf.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
middleware.ResponseConfig `yaml:",inline"`
|
middleware.ResponseConfig `yaml:",inline"`
|
||||||
MetricsAddr string `yaml:"metrics_addr"`
|
MetricsAddr string `yaml:"metrics_addr"`
|
||||||
@@ -57,7 +57,7 @@ func (cfg Config) PostHookNames() (names []string) {
|
|||||||
|
|
||||||
// ConfigFile represents a namespaced YAML configation file.
|
// ConfigFile represents a namespaced YAML configation file.
|
||||||
type ConfigFile struct {
|
type ConfigFile struct {
|
||||||
Chihaya Config `yaml:"chihaya"`
|
Conf Config `yaml:"mochi"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseConfigFile returns a new ConfigFile given the path to a YAML
|
// ParseConfigFile returns a new ConfigFile given the path to a YAML
|
||||||
@@ -12,15 +12,15 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
e2eCmd = &cobra.Command{
|
e2eCmd = &cobra.Command{
|
||||||
Use: "e2e",
|
Use: "e2e",
|
||||||
Short: "exec e2e tests",
|
Short: "exec e2e tests",
|
||||||
Long: "Execute the Chihaya end-to-end test suite",
|
Long: "Execute the Conf end-to-end test suite",
|
||||||
RunE: EndToEndRunCmdFunc,
|
RunE: EndToEndRunCmdFunc,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EndToEndRunCmdFunc implements a Cobra command that runs the end-to-end test
|
// EndToEndRunCmdFunc implements a Cobra command that runs the end-to-end test
|
||||||
// suite for a Chihaya build.
|
// suite for a Conf build.
|
||||||
func EndToEndRunCmdFunc(cmd *cobra.Command, args []string) error {
|
func EndToEndRunCmdFunc(cmd *cobra.Command, args []string) error {
|
||||||
delay, err := cmd.Flags().GetDuration("delay")
|
delay, err := cmd.Flags().GetDuration("delay")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -94,7 +94,7 @@ func testWithInfohash(infoHash bittorrent.InfoHash, url string, delay time.Durat
|
|||||||
resp, err := tracker.Announce{
|
resp, err := tracker.Announce{
|
||||||
TrackerUrl: url,
|
TrackerUrl: url,
|
||||||
Request: req,
|
Request: req,
|
||||||
UserAgent: "chihaya-e2e",
|
UserAgent: "mochi-e2e",
|
||||||
}.Do()
|
}.Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "announce failed")
|
return errors.Wrap(err, "announce failed")
|
||||||
@@ -122,7 +122,7 @@ func testWithInfohash(infoHash bittorrent.InfoHash, url string, delay time.Durat
|
|||||||
resp, err = tracker.Announce{
|
resp, err = tracker.Announce{
|
||||||
TrackerUrl: url,
|
TrackerUrl: url,
|
||||||
Request: req,
|
Request: req,
|
||||||
UserAgent: "chihaya-e2e",
|
UserAgent: "mochi-e2e",
|
||||||
}.Do()
|
}.Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "announce failed")
|
return errors.Wrap(err, "announce failed")
|
||||||
@@ -2,14 +2,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/chihaya/chihaya/frontend/http"
|
|
||||||
"github.com/chihaya/chihaya/frontend/udp"
|
|
||||||
"github.com/chihaya/chihaya/middleware"
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
|
||||||
"github.com/chihaya/chihaya/pkg/metrics"
|
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
|
||||||
"github.com/chihaya/chihaya/storage"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/sot-tech/mochi/frontend/http"
|
||||||
|
"github.com/sot-tech/mochi/frontend/udp"
|
||||||
|
"github.com/sot-tech/mochi/middleware"
|
||||||
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
|
"github.com/sot-tech/mochi/pkg/metrics"
|
||||||
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
|
"github.com/sot-tech/mochi/storage"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
var e2eCmd *cobra.Command
|
var e2eCmd *cobra.Command
|
||||||
|
|
||||||
// Run represents the state of a running instance of Chihaya.
|
// Run represents the state of a running instance of Conf.
|
||||||
type Run struct {
|
type Run struct {
|
||||||
configFilePath string
|
configFilePath string
|
||||||
storage storage.Storage
|
storage storage.Storage
|
||||||
@@ -28,7 +28,7 @@ type Run struct {
|
|||||||
sg *stop.Group
|
sg *stop.Group
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRun runs an instance of Chihaya.
|
// NewRun runs an instance of Conf.
|
||||||
func NewRun(configFilePath string) (*Run, error) {
|
func NewRun(configFilePath string) (*Run, error) {
|
||||||
r := &Run{
|
r := &Run{
|
||||||
configFilePath: configFilePath,
|
configFilePath: configFilePath,
|
||||||
@@ -37,7 +37,7 @@ func NewRun(configFilePath string) (*Run, error) {
|
|||||||
return r, r.Start(nil)
|
return r, r.Start(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start begins an instance of Chihaya.
|
// Start begins an instance of Conf.
|
||||||
// It is optional to provide an instance of the peer store to avoid the
|
// It is optional to provide an instance of the peer store to avoid the
|
||||||
// creation of a new one.
|
// creation of a new one.
|
||||||
func (r *Run) Start(ps storage.Storage) error {
|
func (r *Run) Start(ps storage.Storage) error {
|
||||||
@@ -45,7 +45,7 @@ func (r *Run) Start(ps storage.Storage) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("failed to read config: " + err.Error())
|
return errors.New("failed to read config: " + err.Error())
|
||||||
}
|
}
|
||||||
cfg := configFile.Chihaya
|
cfg := configFile.Conf
|
||||||
|
|
||||||
r.sg = stop.NewGroup()
|
r.sg = stop.NewGroup()
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ func combineErrors(prefix string, errs []error) error {
|
|||||||
return errors.New(prefix + ": " + strings.Join(errStrs, "; "))
|
return errors.New(prefix + ": " + strings.Join(errStrs, "; "))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop shuts down an instance of Chihaya.
|
// Stop shuts down an instance of Conf.
|
||||||
func (r *Run) Stop(keepPeerStore bool) (storage.Storage, error) {
|
func (r *Run) Stop(keepPeerStore bool) (storage.Storage, error) {
|
||||||
log.Debug("stopping frontends and metrics server")
|
log.Debug("stopping frontends and metrics server")
|
||||||
if errs := r.sg.Stop().Wait(); len(errs) != 0 {
|
if errs := r.sg.Stop().Wait(); len(errs) != 0 {
|
||||||
@@ -134,7 +134,7 @@ func (r *Run) Stop(keepPeerStore bool) (storage.Storage, error) {
|
|||||||
return r.storage, nil
|
return r.storage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RootRunCmdFunc implements a Cobra command that runs an instance of Chihaya
|
// RootRunCmdFunc implements a Cobra command that runs an instance of Conf
|
||||||
// and handles reloading and shutdown via process signals.
|
// and handles reloading and shutdown via process signals.
|
||||||
func RootRunCmdFunc(cmd *cobra.Command, _ []string) error {
|
func RootRunCmdFunc(cmd *cobra.Command, _ []string) error {
|
||||||
configFilePath, err := cmd.Flags().GetString("config")
|
configFilePath, err := cmd.Flags().GetString("config")
|
||||||
@@ -214,7 +214,7 @@ func RootPostRunCmdFunc(_ *cobra.Command, _ []string) error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "chihaya",
|
Use: "mochi",
|
||||||
Short: "BitTorrent Tracker",
|
Short: "BitTorrent Tracker",
|
||||||
Long: "A customizable, multi-protocol BitTorrent Tracker",
|
Long: "A customizable, multi-protocol BitTorrent Tracker",
|
||||||
PersistentPreRunE: RootPreRunCmdFunc,
|
PersistentPreRunE: RootPreRunCmdFunc,
|
||||||
@@ -230,7 +230,7 @@ func main() {
|
|||||||
rootCmd.PersistentFlags().Bool("nocolors", false, "disable log coloring")
|
rootCmd.PersistentFlags().Bool("nocolors", false, "disable log coloring")
|
||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.Flags().String("config", "/etc/chihaya.yaml", "location of configuration file")
|
rootCmd.Flags().String("config", "/etc/mochi.yaml", "location of configuration file")
|
||||||
|
|
||||||
if e2eCmd != nil {
|
if e2eCmd != nil {
|
||||||
rootCmd.AddCommand(e2eCmd)
|
rootCmd.AddCommand(e2eCmd)
|
||||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
chihaya:
|
mochi:
|
||||||
# The interval communicated with BitTorrent clients informing them how
|
# The interval communicated with BitTorrent clients informing them how
|
||||||
# frequently they should announce in between client events.
|
# frequently they should announce in between client events.
|
||||||
announce_interval: 30m
|
announce_interval: 30m
|
||||||
@@ -169,7 +169,7 @@ chihaya:
|
|||||||
#- name: jwt
|
#- name: jwt
|
||||||
# options:
|
# options:
|
||||||
# issuer: "https://issuer.com"
|
# issuer: "https://issuer.com"
|
||||||
# audience: "https://chihaya.issuer.com"
|
# audience: "https://some.issuer.com"
|
||||||
# jwk_set_url: "https://issuer.com/keys"
|
# jwk_set_url: "https://issuer.com/keys"
|
||||||
# jwk_set_update_interval: 5m
|
# jwk_set_update_interval: 5m
|
||||||
|
|
||||||
|
|||||||
Vendored
-21
@@ -1,21 +0,0 @@
|
|||||||
# Patterns to ignore when building packages.
|
|
||||||
# This supports shell glob matching, relative path matching, and
|
|
||||||
# negation (prefixed with !). Only one pattern per line.
|
|
||||||
.DS_Store
|
|
||||||
# Common VCS dirs
|
|
||||||
.git/
|
|
||||||
.gitignore
|
|
||||||
.bzr/
|
|
||||||
.bzrignore
|
|
||||||
.hg/
|
|
||||||
.hgignore
|
|
||||||
.svn/
|
|
||||||
# Common backup files
|
|
||||||
*.swp
|
|
||||||
*.bak
|
|
||||||
*.tmp
|
|
||||||
*~
|
|
||||||
# Various IDEs
|
|
||||||
.project
|
|
||||||
.idea/
|
|
||||||
*.tmproj
|
|
||||||
Vendored
-10
@@ -1,10 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
name: chihaya
|
|
||||||
home: https://chihaya.io
|
|
||||||
version: 0.1.0
|
|
||||||
description: A Helm chart for running the Chihaya BitTorrent tracker on Kubernetes.
|
|
||||||
sources:
|
|
||||||
- https://github.com/chihaya/chihaya
|
|
||||||
maintainers:
|
|
||||||
- name: Jimmy Zelinskie
|
|
||||||
email: jimmyzelinskie@gmail.com
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
You can port forward a local port to Prometheus or the HTTP tracker by running:
|
|
||||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
|
|
||||||
# Metrics port
|
|
||||||
kubectl port-forward $POD_NAME 8080:{{ $v := .Values.config.chihaya.metrics_addr | split ":" }}{{ $v._1 }}
|
|
||||||
# HTTP tracker port
|
|
||||||
kubectl port-forward $POD_NAME 8080:{{ $v := .Values.config.chihaya.http.addr | split ":" }}{{ $v._1 }}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
|
||||||
{{/*
|
|
||||||
Expand the name of the chart.
|
|
||||||
*/}}
|
|
||||||
{{- define "name" -}}
|
|
||||||
{{- default .Chart.Name .Values.nameOverride | trunc 24 -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{/*
|
|
||||||
Create a default fully qualified app name.
|
|
||||||
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
||||||
*/}}
|
|
||||||
{{- define "fullname" -}}
|
|
||||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
|
||||||
{{- printf "%s-%s" .Release.Name $name | trunc 24 -}}
|
|
||||||
{{- end -}}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: { { template "fullname" . } }
|
|
||||||
labels:
|
|
||||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
|
||||||
data:
|
|
||||||
config.yaml: |
|
|
||||||
{ { toYaml .Values.config | indent 4 } }
|
|
||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
apiVersion: extensions/v1beta1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: { { template "fullname" . } }
|
|
||||||
labels:
|
|
||||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
|
||||||
spec:
|
|
||||||
replicas: { { .Values.replicaCount } }
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: { { template "fullname" . } }
|
|
||||||
spec:
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: { { template "fullname" . } }
|
|
||||||
containers:
|
|
||||||
- name: { { .Chart.Name } }
|
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
||||||
imagePullPolicy: { { .Values.image.pullPolicy } }
|
|
||||||
args:
|
|
||||||
- "--config=/etc/chihaya/config.yaml"
|
|
||||||
- "--debug"
|
|
||||||
- "--json"
|
|
||||||
ports:
|
|
||||||
- name: bittorrent-http
|
|
||||||
containerPort: { { $v := .Values.config.chihaya.http.addr | split ":" } }{ { $v._1 } }
|
|
||||||
protocol: TCP
|
|
||||||
- name: bittorrent-udp
|
|
||||||
containerPort: { { $v := .Values.config.chihaya.udp.addr | split ":" } }{ { $v._1 } }
|
|
||||||
protocol: UDP
|
|
||||||
- name: metrics
|
|
||||||
containerPort: { { $v := .Values.config.chihaya.metrics_addr | split ":" } }{ { $v._1 } }
|
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /
|
|
||||||
port: { { $v := .Values.config.chihaya.metrics_addr | split ":" } }{ { $v._1 } }
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /etc/chihaya
|
|
||||||
resources:
|
|
||||||
{ { toYaml .Values.resources | indent 10 } }
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: { { template "fullname" . } }
|
|
||||||
labels:
|
|
||||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
|
||||||
annotations:
|
|
||||||
prometheus.io/scrape: "true"
|
|
||||||
prometheus.io/path: "/metrics"
|
|
||||||
prometheus.io/port: { { $v := .Values.config.chihaya.metrics_addr | split ":" } }{ { $v._1 | quote } }
|
|
||||||
spec:
|
|
||||||
type: { { .Values.service.type } }
|
|
||||||
ports:
|
|
||||||
- name: bittorrent-http
|
|
||||||
port: { { $v := .Values.config.chihaya.http.addr | split ":" } }{ { $v._1 } }
|
|
||||||
targetPort: { { $v := .Values.config.chihaya.http.addr | split ":" } }{ { $v._1 } }
|
|
||||||
protocol: TCP
|
|
||||||
- name: bittorrent-udp
|
|
||||||
port: { { $v := .Values.config.chihaya.udp.addr | split ":" } }{ { $v._1 } }
|
|
||||||
targetPort: { { $v := .Values.config.chihaya.udp.addr | split ":" } }{ { $v._1 } }
|
|
||||||
protocol: UDP
|
|
||||||
- name: metrics
|
|
||||||
port: { { $v := .Values.config.chihaya.metrics_addr | split ":" } }{ { $v._1 } }
|
|
||||||
targetPort: { { $v := .Values.config.chihaya.metrics_addr | split ":" } }{ { $v._1 } }
|
|
||||||
protocol: TCP
|
|
||||||
selector:
|
|
||||||
app: { { template "fullname" . } }
|
|
||||||
Vendored
-162
@@ -1,162 +0,0 @@
|
|||||||
replicaCount: 1
|
|
||||||
image:
|
|
||||||
repository: quay.io/jzelinskie/chihaya-git
|
|
||||||
tag: latest
|
|
||||||
pullPolicy: IfNotPresent
|
|
||||||
service:
|
|
||||||
name: chihaya
|
|
||||||
type: ClusterIP
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 1Gi
|
|
||||||
config:
|
|
||||||
chihaya:
|
|
||||||
# The interval communicated with BitTorrent clients informing them how
|
|
||||||
# frequently they should announce in between client events.
|
|
||||||
announce_interval: 30m
|
|
||||||
|
|
||||||
# The interval communicated with BitTorrent clients informing them of the
|
|
||||||
# minimal duration between announces.
|
|
||||||
min_announce_interval: 15m
|
|
||||||
|
|
||||||
# The network interface that will bind to an HTTP endpoint that can be
|
|
||||||
# scraped by programs collecting metrics.
|
|
||||||
#
|
|
||||||
# /metrics serves metrics in the Prometheus format
|
|
||||||
# /debug/pprof/{cmdline,profile,symbol,trace} serves profiles in the pprof format
|
|
||||||
metrics_addr: "0.0.0.0:6880"
|
|
||||||
|
|
||||||
# The maximum number of peers returned in an announce.
|
|
||||||
max_numwant: 50
|
|
||||||
|
|
||||||
# The default number of peers returned in an announce.
|
|
||||||
default_numwant: 25
|
|
||||||
|
|
||||||
# The number of infohashes a single scrape can request before being truncated.
|
|
||||||
max_scrape_infohashes: 50
|
|
||||||
|
|
||||||
# This block defines configuration for the tracker's HTTP interface.
|
|
||||||
# If you do not wish to run this, delete this section.
|
|
||||||
http:
|
|
||||||
# The network interface that will bind to an HTTP server for serving
|
|
||||||
# BitTorrent traffic.
|
|
||||||
addr: "0.0.0.0:6969"
|
|
||||||
|
|
||||||
# The path to the required files to listen via HTTPS.
|
|
||||||
tls_cert_path: ""
|
|
||||||
tls_key_path: ""
|
|
||||||
|
|
||||||
# The timeout durations for HTTP requests.
|
|
||||||
read_timeout: 5s
|
|
||||||
write_timeout: 5s
|
|
||||||
|
|
||||||
# Whether to time requests.
|
|
||||||
# Disabling this should increase performance/decrease load.
|
|
||||||
enable_request_timing: false
|
|
||||||
|
|
||||||
# When true, persistent connections will be allowed. Generally this is not
|
|
||||||
# useful for a public tracker, but helps performance in some cases (use of
|
|
||||||
# a reverse proxy, or when there are few clients issuing many requests).
|
|
||||||
enable_keepalive: false
|
|
||||||
idle_timeout: 30s
|
|
||||||
|
|
||||||
# Whether to listen on /announce.php and /scrape.php in addition to their
|
|
||||||
# non-.php counterparts.
|
|
||||||
# This is an option for compatibility with (very) old clients or otherwise
|
|
||||||
# outdated systems.
|
|
||||||
# This might be useful to retracker.local users, for more information see
|
|
||||||
# http://rutracker.wiki/Оптимизация_обмена_битторрент_траффиком_в_локальных_сетях
|
|
||||||
# and
|
|
||||||
# http://rutracker.wiki/Retracker.local
|
|
||||||
enable_legacy_php_urls: false
|
|
||||||
|
|
||||||
# When enabled, the IP address used to connect to the tracker will not
|
|
||||||
# override the value clients advertise as their IP address.
|
|
||||||
allow_ip_spoofing: false
|
|
||||||
|
|
||||||
# The HTTP Header containing the IP address of the client.
|
|
||||||
# This is only necessary if using a reverse proxy.
|
|
||||||
real_ip_header: "x-real-ip"
|
|
||||||
|
|
||||||
# The maximum number of peers returned for an individual request.
|
|
||||||
max_numwant: 100
|
|
||||||
|
|
||||||
# The default number of peers returned for an individual request.
|
|
||||||
default_numwant: 50
|
|
||||||
|
|
||||||
# The maximum number of infohashes that can be scraped in one request.
|
|
||||||
max_scrape_infohashes: 50
|
|
||||||
|
|
||||||
# This block defines configuration for the tracker's UDP interface.
|
|
||||||
# If you do not wish to run this, delete this section.
|
|
||||||
udp:
|
|
||||||
# The network interface that will bind to a UDP server for serving
|
|
||||||
# BitTorrent traffic.
|
|
||||||
addr: "0.0.0.0:6969"
|
|
||||||
|
|
||||||
# The leeway for a timestamp on a connection ID.
|
|
||||||
max_clock_skew: 10s
|
|
||||||
|
|
||||||
# The key used to encrypt connection IDs.
|
|
||||||
private_key: "paste a random string here that will be used to hmac connection IDs"
|
|
||||||
|
|
||||||
# Whether to time requests.
|
|
||||||
# Disabling this should increase performance/decrease load.
|
|
||||||
enable_request_timing: false
|
|
||||||
|
|
||||||
# When enabled, the IP address used to connect to the tracker will not
|
|
||||||
# override the value clients advertise as their IP address.
|
|
||||||
allow_ip_spoofing: false
|
|
||||||
|
|
||||||
# The maximum number of peers returned for an individual request.
|
|
||||||
max_numwant: 100
|
|
||||||
|
|
||||||
# The default number of peers returned for an individual request.
|
|
||||||
default_numwant: 50
|
|
||||||
|
|
||||||
# The maximum number of infohashes that can be scraped in one request.
|
|
||||||
max_scrape_infohashes: 50
|
|
||||||
|
|
||||||
|
|
||||||
# This block defines configuration used for the storage of peer data.
|
|
||||||
storage:
|
|
||||||
name: memory
|
|
||||||
config:
|
|
||||||
# The frequency which stale peers are removed.
|
|
||||||
gc_interval: 3m
|
|
||||||
|
|
||||||
# The amount of time until a peer is considered stale.
|
|
||||||
# To avoid churn, keep this slightly larger than `announce_interval`
|
|
||||||
peer_lifetime: 31m
|
|
||||||
|
|
||||||
# The number of partitions data will be divided into in order to provide a
|
|
||||||
# higher degree of parallelism.
|
|
||||||
shard_count: 1024
|
|
||||||
|
|
||||||
# The interval at which metrics about the number of infohashes and peers
|
|
||||||
# are collected and posted to Prometheus.
|
|
||||||
prometheus_reporting_interval: 1s
|
|
||||||
|
|
||||||
# This block defines configuration used for middleware executed before a
|
|
||||||
# response has been returned to a BitTorrent client.
|
|
||||||
prehooks:
|
|
||||||
#- name: jwt
|
|
||||||
# options:
|
|
||||||
# issuer: "https://issuer.com"
|
|
||||||
# audience: "https://chihaya.issuer.com"
|
|
||||||
# jwk_set_url: "https://issuer.com/keys"
|
|
||||||
# jwk_set_update_interval: 5m
|
|
||||||
|
|
||||||
#- name: client approval
|
|
||||||
# options:
|
|
||||||
# whitelist:
|
|
||||||
# - "OP1011"
|
|
||||||
# blacklist:
|
|
||||||
# - "OP1012"
|
|
||||||
|
|
||||||
#- name: interval variation
|
|
||||||
# options:
|
|
||||||
# modify_response_probability: 0.2
|
|
||||||
# max_increase_delta: 60
|
|
||||||
# modify_min_interval: true
|
|
||||||
Vendored
+2
-2
@@ -5,7 +5,7 @@ global:
|
|||||||
# A scrape configuration containing exactly one endpoint to scrape:
|
# A scrape configuration containing exactly one endpoint to scrape:
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
||||||
- job_name: 'local-chihaya' # you can name this however you want
|
- job_name: 'local-mochi' # you can name this however you want
|
||||||
scrape_interval: 5s # optionally override the global scrape_interval
|
scrape_interval: 5s # optionally override the global scrape_interval
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: [ 'localhost:6881' ] # provide the address of chihaya's prometheus endpoint
|
- targets: [ 'localhost:6881' ] # provide the address of mochi's prometheus endpoint
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
digraph G {
|
|
||||||
subgraph cluster_0 {
|
|
||||||
label = "chihaya";
|
|
||||||
style = "line";
|
|
||||||
color = "blue";
|
|
||||||
|
|
||||||
"Storage";
|
|
||||||
|
|
||||||
subgraph cluster_1 {
|
|
||||||
label = "frontend";
|
|
||||||
style = "line";
|
|
||||||
color = "hotpink";
|
|
||||||
|
|
||||||
"Parser";
|
|
||||||
"Writer";
|
|
||||||
}
|
|
||||||
|
|
||||||
subgraph cluster_2 {
|
|
||||||
label = "logic";
|
|
||||||
style = "line";
|
|
||||||
color = "purple";
|
|
||||||
|
|
||||||
"PreHook Middleware";
|
|
||||||
"PostHook Middleware";
|
|
||||||
"Response Generator";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"BitTorrent Client" -> "Parser";
|
|
||||||
"Parser" -> "PreHook Middleware";
|
|
||||||
"PreHook Middleware" -> "Response Generator";
|
|
||||||
"PostHook Middleware" -> "Storage";
|
|
||||||
"Storage" -> "Response Generator";
|
|
||||||
"Response Generator" -> "Writer";
|
|
||||||
"Writer" -> "BitTorrent Client";
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,3 @@ the configured implementation of the _Storage_ interface. PostHooks are asynchro
|
|||||||
has been delivered to the client. Because they are unnecessary to for generating a response, updates to the Storage for
|
has been delivered to the client. Because they are unnecessary to for generating a response, updates to the Storage for
|
||||||
a particular request are done asynchronously in a PostHook.
|
a particular request are done asynchronously in a PostHook.
|
||||||
|
|
||||||
### Diagram
|
|
||||||
|
|
||||||

|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ This middleware provides the following parameters for configuration:
|
|||||||
An example config might look like this:
|
An example config might look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
chihaya:
|
mochi:
|
||||||
prehooks:
|
prehooks:
|
||||||
- name: interval variation
|
- name: interval variation
|
||||||
config:
|
config:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ When one instance of Chihaya is down, other instances can continue serving peers
|
|||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
chihaya:
|
mochi:
|
||||||
storage:
|
storage:
|
||||||
name: redis
|
name: redis
|
||||||
config:
|
config:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package frontend
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TrackerLogic is the interface used by a frontend in order to: (1) generate a
|
// TrackerLogic is the interface used by a frontend in order to: (1) generate a
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import (
|
|||||||
|
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/frontend"
|
"github.com/sot-tech/mochi/frontend"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config represents all of the configurable options for an HTTP BitTorrent
|
// Config represents all of the configurable options for an HTTP BitTorrent
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseOptions is the configuration used to parse an Announce Request.
|
// ParseOptions is the configuration used to parse an Announce Request.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/anacrolix/torrent/bencode"
|
"github.com/anacrolix/torrent/bencode"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestWriteError(t *testing.T) {
|
func TestWriteError(t *testing.T) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/sha256-simd"
|
"github.com/minio/sha256-simd"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ttl is the duration a connection ID should be valid according to BEP 15.
|
// ttl is the duration a connection ID should be valid according to BEP 15.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/minio/sha256-simd"
|
"github.com/minio/sha256-simd"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var golden = []struct {
|
var golden = []struct {
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/frontend"
|
"github.com/sot-tech/mochi/frontend"
|
||||||
"github.com/chihaya/chihaya/frontend/udp/bytepool"
|
"github.com/sot-tech/mochi/frontend/udp/bytepool"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
"github.com/chihaya/chihaya/pkg/timecache"
|
"github.com/sot-tech/mochi/pkg/timecache"
|
||||||
)
|
)
|
||||||
|
|
||||||
var allowedGeneratedPrivateKeyRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
var allowedGeneratedPrivateKeyRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package udp_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/frontend/udp"
|
"github.com/sot-tech/mochi/frontend/udp"
|
||||||
"github.com/chihaya/chihaya/middleware"
|
"github.com/sot-tech/mochi/middleware"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
_ "github.com/chihaya/chihaya/storage/memory"
|
_ "github.com/sot-tech/mochi/storage/memory"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStartStopRaceIssue437(t *testing.T) {
|
func TestStartStopRaceIssue437(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteError writes the failure reason as a null-terminated string.
|
// WriteError writes the failure reason as a null-terminated string.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/chihaya/chihaya
|
module github.com/sot-tech/mochi
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// - https://github.com/webtorrent/bittorrent-peerid/blob/master/lib/utils.js
|
// - https://github.com/webtorrent/bittorrent-peerid/blob/master/lib/utils.js
|
||||||
package clientapproval
|
package clientapproval
|
||||||
|
|
||||||
import "github.com/chihaya/chihaya/bittorrent"
|
import "github.com/sot-tech/mochi/bittorrent"
|
||||||
|
|
||||||
// ClientID represents the part of a PeerID that identifies a Peer's client
|
// ClientID represents the part of a PeerID that identifies a Peer's client
|
||||||
// software.
|
// software.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package clientapproval
|
package clientapproval
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/middleware"
|
"github.com/sot-tech/mochi/middleware"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name by which this middleware is registered with Chihaya.
|
// Name is the name by which this middleware is registered with Conf.
|
||||||
const Name = "client approval"
|
const Name = "client approval"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package clientapproval
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hook abstracts the concept of anything that needs to interact with a
|
// Hook abstracts the concept of anything that needs to interact with a
|
||||||
|
|||||||
@@ -16,19 +16,19 @@ import (
|
|||||||
jc "github.com/SermoDigital/jose/crypto"
|
jc "github.com/SermoDigital/jose/crypto"
|
||||||
"github.com/SermoDigital/jose/jws"
|
"github.com/SermoDigital/jose/jws"
|
||||||
"github.com/SermoDigital/jose/jwt"
|
"github.com/SermoDigital/jose/jwt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
|
||||||
"github.com/chihaya/chihaya/middleware"
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
|
||||||
"github.com/chihaya/chihaya/storage"
|
|
||||||
"github.com/mendsley/gojwk"
|
"github.com/mendsley/gojwk"
|
||||||
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
|
"github.com/sot-tech/mochi/middleware"
|
||||||
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
|
"github.com/sot-tech/mochi/storage"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name by which this middleware is registered with Chihaya.
|
// Name is the name by which this middleware is registered with Conf.
|
||||||
const Name = "jwt"
|
const Name = "jwt"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
+6
-6
@@ -2,18 +2,18 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/frontend"
|
"github.com/sot-tech/mochi/frontend"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ResponseConfig holds the configuration used for the actual response.
|
// ResponseConfig holds the configuration used for the actual response.
|
||||||
//
|
//
|
||||||
// TODO(jzelinskie): Evaluate whether we would like to make this optional.
|
// TODO(jzelinskie): Evaluate whether we would like to make this optional.
|
||||||
// We can make Chihaya extensible enough that you can program a new response
|
// We can make Conf extensible enough that you can program a new response
|
||||||
// generator at the cost of making it possible for users to create config that
|
// generator at the cost of making it possible for users to create config that
|
||||||
// won't compose a functional tracker.
|
// won't compose a functional tracker.
|
||||||
type ResponseConfig struct {
|
type ResponseConfig struct {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nopHook is a Hook to measure the overhead of a no-operation Hook through
|
// nopHook is a Hook to measure the overhead of a no-operation Hook through
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package random
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeriveEntropyFromRequest generates 2*64 bits of pseudo random state from an
|
// DeriveEntropyFromRequest generates 2*64 bits of pseudo random state from an
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package container
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anacrolix/torrent/metainfo"
|
"github.com/anacrolix/torrent/metainfo"
|
||||||
"github.com/anacrolix/torrent/util/dirwatch"
|
"github.com/anacrolix/torrent/util/dirwatch"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
|
||||||
"github.com/chihaya/chihaya/middleware/torrentapproval/container"
|
|
||||||
"github.com/chihaya/chihaya/middleware/torrentapproval/container/list"
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
|
||||||
"github.com/chihaya/chihaya/storage"
|
|
||||||
"github.com/minio/sha256-simd"
|
"github.com/minio/sha256-simd"
|
||||||
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
|
"github.com/sot-tech/mochi/middleware/torrentapproval/container"
|
||||||
|
"github.com/sot-tech/mochi/middleware/torrentapproval/container/list"
|
||||||
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
|
"github.com/sot-tech/mochi/storage"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ package list
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/middleware/torrentapproval/container"
|
"github.com/sot-tech/mochi/middleware/torrentapproval/container"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,19 @@ package torrentapproval
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/middleware"
|
"github.com/sot-tech/mochi/middleware"
|
||||||
"github.com/chihaya/chihaya/middleware/torrentapproval/container"
|
"github.com/sot-tech/mochi/middleware/torrentapproval/container"
|
||||||
// import directory watcher to enable appropriate support
|
// import directory watcher to enable appropriate support
|
||||||
_ "github.com/chihaya/chihaya/middleware/torrentapproval/container/directory"
|
_ "github.com/sot-tech/mochi/middleware/torrentapproval/container/directory"
|
||||||
// import static list to enable appropriate support
|
// import static list to enable appropriate support
|
||||||
_ "github.com/chihaya/chihaya/middleware/torrentapproval/container/list"
|
_ "github.com/sot-tech/mochi/middleware/torrentapproval/container/list"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name by which this middleware is registered with Chihaya.
|
// Name is the name by which this middleware is registered with Conf.
|
||||||
const Name = "torrent approval"
|
const Name = "torrent approval"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package torrentapproval
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/storage/memory"
|
"github.com/sot-tech/mochi/storage/memory"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"testing"
|
"testing"
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/middleware"
|
"github.com/sot-tech/mochi/middleware"
|
||||||
"github.com/chihaya/chihaya/middleware/pkg/random"
|
"github.com/sot-tech/mochi/middleware/pkg/random"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name by which this middleware is registered with Chihaya.
|
// Name is the name by which this middleware is registered with Conf.
|
||||||
const Name = "interval variation"
|
const Name = "interval variation"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package varinterval
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server represents a standalone HTTP server for serving a Prometheus metrics
|
// Server represents a standalone HTTP server for serving a Prometheus metrics
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Package memory implements the storage interface for a Chihaya
|
// Package memory implements the storage interface for a Conf
|
||||||
// BitTorrent tracker keeping peer data in memory.
|
// BitTorrent tracker keeping peer data in memory.
|
||||||
package memory
|
package memory
|
||||||
|
|
||||||
@@ -12,14 +12,14 @@ import (
|
|||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
"github.com/chihaya/chihaya/pkg/timecache"
|
"github.com/sot-tech/mochi/pkg/timecache"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name by which this peer store is registered with Chihaya.
|
// Name is the name by which this peer store is registered with Conf.
|
||||||
const Name = "memory"
|
const Name = "memory"
|
||||||
|
|
||||||
// Default config constants.
|
// Default config constants.
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package memory
|
package memory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"github.com/chihaya/chihaya/storage/test"
|
"github.com/sot-tech/mochi/storage/test"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Package redis implements the storage interface for a Chihaya
|
// Package redis implements the storage interface for a Conf
|
||||||
// BitTorrent tracker keeping peer data in redis with hash.
|
// BitTorrent tracker keeping peer data in redis with hash.
|
||||||
// There two categories of hash:
|
// There two categories of hash:
|
||||||
//
|
//
|
||||||
@@ -32,14 +32,14 @@ import (
|
|||||||
"github.com/gomodule/redigo/redis"
|
"github.com/gomodule/redigo/redis"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
"github.com/chihaya/chihaya/pkg/timecache"
|
"github.com/sot-tech/mochi/pkg/timecache"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name by which this peer store is registered with Chihaya.
|
// Name is the name by which this peer store is registered with Conf.
|
||||||
const Name = "redis"
|
const Name = "redis"
|
||||||
|
|
||||||
// Default config constants.
|
// Default config constants.
|
||||||
@@ -850,7 +850,7 @@ func (ps *store) Stop() stop.Result {
|
|||||||
go func() {
|
go func() {
|
||||||
close(ps.closed)
|
close(ps.closed)
|
||||||
ps.wg.Wait()
|
ps.wg.Wait()
|
||||||
log.Info("storage: exiting. chihaya does not clear data in redis when exiting. chihaya keys have prefix 'IPv{4,6}_'.")
|
log.Info("storage: exiting. mochi does not clear data in redis when exiting. mochi keys have prefix 'IPv{4,6}_'.")
|
||||||
c.Done()
|
c.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alicebob/miniredis"
|
"github.com/alicebob/miniredis"
|
||||||
s "github.com/chihaya/chihaya/storage"
|
s "github.com/sot-tech/mochi/storage"
|
||||||
"github.com/chihaya/chihaya/storage/test"
|
"github.com/sot-tech/mochi/storage/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createNew() s.Storage {
|
func createNew() s.Storage {
|
||||||
|
|||||||
+3
-3
@@ -4,9 +4,9 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/sot-tech/mochi/pkg/log"
|
||||||
"github.com/chihaya/chihaya/pkg/stop"
|
"github.com/sot-tech/mochi/pkg/stop"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"github.com/chihaya/chihaya/storage"
|
"github.com/sot-tech/mochi/storage"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/sot-tech/mochi/bittorrent"
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user