Rename to MoChi

This commit is contained in:
Lawrence, Rendall
2021-12-21 15:07:11 +03:00
parent 5a1ac73a3d
commit 4dbbb4ad83
72 changed files with 185 additions and 726 deletions
+11 -11
View File
@@ -6,19 +6,19 @@ import (
"gopkg.in/yaml.v2"
"github.com/chihaya/chihaya/frontend/http"
"github.com/chihaya/chihaya/frontend/udp"
"github.com/chihaya/chihaya/middleware"
"github.com/sot-tech/mochi/frontend/http"
"github.com/sot-tech/mochi/frontend/udp"
"github.com/sot-tech/mochi/middleware"
// Imports to register middleware drivers.
_ "github.com/chihaya/chihaya/middleware/clientapproval"
_ "github.com/chihaya/chihaya/middleware/jwt"
_ "github.com/chihaya/chihaya/middleware/torrentapproval"
_ "github.com/chihaya/chihaya/middleware/varinterval"
_ "github.com/sot-tech/mochi/middleware/clientapproval"
_ "github.com/sot-tech/mochi/middleware/jwt"
_ "github.com/sot-tech/mochi/middleware/torrentapproval"
_ "github.com/sot-tech/mochi/middleware/varinterval"
// Imports to register storage drivers.
_ "github.com/chihaya/chihaya/storage/memory"
_ "github.com/chihaya/chihaya/storage/redis"
_ "github.com/sot-tech/mochi/storage/memory"
_ "github.com/sot-tech/mochi/storage/redis"
)
type storageConfig struct {
@@ -26,7 +26,7 @@ type storageConfig struct {
Config interface{} `yaml:"config"`
}
// Config represents the configuration used for executing Chihaya.
// Config represents the configuration used for executing Conf.
type Config struct {
middleware.ResponseConfig `yaml:",inline"`
MetricsAddr string `yaml:"metrics_addr"`
@@ -57,7 +57,7 @@ func (cfg Config) PostHookNames() (names []string) {
// ConfigFile represents a namespaced YAML configation file.
type ConfigFile struct {
Chihaya Config `yaml:"chihaya"`
Conf Config `yaml:"mochi"`
}
// ParseConfigFile returns a new ConfigFile given the path to a YAML
+6 -6
View File
@@ -12,15 +12,15 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/chihaya/chihaya/bittorrent"
"github.com/chihaya/chihaya/pkg/log"
"github.com/sot-tech/mochi/bittorrent"
"github.com/sot-tech/mochi/pkg/log"
)
func init() {
e2eCmd = &cobra.Command{
Use: "e2e",
Short: "exec e2e tests",
Long: "Execute the Chihaya end-to-end test suite",
Long: "Execute the Conf end-to-end test suite",
RunE: EndToEndRunCmdFunc,
}
@@ -30,7 +30,7 @@ func init() {
}
// 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 {
delay, err := cmd.Flags().GetDuration("delay")
if err != nil {
@@ -94,7 +94,7 @@ func testWithInfohash(infoHash bittorrent.InfoHash, url string, delay time.Durat
resp, err := tracker.Announce{
TrackerUrl: url,
Request: req,
UserAgent: "chihaya-e2e",
UserAgent: "mochi-e2e",
}.Do()
if err != nil {
return errors.Wrap(err, "announce failed")
@@ -122,7 +122,7 @@ func testWithInfohash(infoHash bittorrent.InfoHash, url string, delay time.Durat
resp, err = tracker.Announce{
TrackerUrl: url,
Request: req,
UserAgent: "chihaya-e2e",
UserAgent: "mochi-e2e",
}.Do()
if err != nil {
return errors.Wrap(err, "announce failed")
+15 -15
View File
@@ -2,14 +2,14 @@ package main
import (
"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/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"
"os"
"os/signal"
@@ -20,7 +20,7 @@ import (
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 {
configFilePath string
storage storage.Storage
@@ -28,7 +28,7 @@ type Run struct {
sg *stop.Group
}
// NewRun runs an instance of Chihaya.
// NewRun runs an instance of Conf.
func NewRun(configFilePath string) (*Run, error) {
r := &Run{
configFilePath: configFilePath,
@@ -37,7 +37,7 @@ func NewRun(configFilePath string) (*Run, error) {
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
// creation of a new one.
func (r *Run) Start(ps storage.Storage) error {
@@ -45,7 +45,7 @@ func (r *Run) Start(ps storage.Storage) error {
if err != nil {
return errors.New("failed to read config: " + err.Error())
}
cfg := configFile.Chihaya
cfg := configFile.Conf
r.sg = stop.NewGroup()
@@ -111,7 +111,7 @@ func combineErrors(prefix string, errs []error) error {
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) {
log.Debug("stopping frontends and metrics server")
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
}
// 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.
func RootRunCmdFunc(cmd *cobra.Command, _ []string) error {
configFilePath, err := cmd.Flags().GetString("config")
@@ -214,7 +214,7 @@ func RootPostRunCmdFunc(_ *cobra.Command, _ []string) error {
func main() {
var rootCmd = &cobra.Command{
Use: "chihaya",
Use: "mochi",
Short: "BitTorrent Tracker",
Long: "A customizable, multi-protocol BitTorrent Tracker",
PersistentPreRunE: RootPreRunCmdFunc,
@@ -230,7 +230,7 @@ func main() {
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 {
rootCmd.AddCommand(e2eCmd)