mirror of
https://github.com/bolucat/Archive.git
synced 2025-09-26 20:21:35 +08:00
Update On Thu Jul 31 20:43:49 CEST 2025
This commit is contained in:
@@ -32,7 +32,7 @@ PROJECT_NAME=$(shell basename "${ROOT}")
|
||||
# - pkg/version/current.go
|
||||
#
|
||||
# Use `tools/bump_version.sh` script to change all those files at one shot.
|
||||
VERSION="3.17.0"
|
||||
VERSION="3.17.1"
|
||||
|
||||
# Build binaries and installation packages.
|
||||
.PHONY: build
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Package: mieru
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Section: net
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Name: mieru
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Release: 1%{?dist}
|
||||
Summary: Mieru proxy client
|
||||
License: GPLv3+
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Package: mieru
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Section: net
|
||||
Priority: optional
|
||||
Architecture: arm64
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Name: mieru
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Release: 1%{?dist}
|
||||
Summary: Mieru proxy client
|
||||
License: GPLv3+
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Package: mita
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Section: net
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Name: mita
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Release: 1%{?dist}
|
||||
Summary: Mieru proxy server
|
||||
License: GPLv3+
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Package: mita
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Section: net
|
||||
Priority: optional
|
||||
Architecture: arm64
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Name: mita
|
||||
Version: 3.17.0
|
||||
Version: 3.17.1
|
||||
Release: 1%{?dist}
|
||||
Summary: Mieru proxy server
|
||||
License: GPLv3+
|
||||
|
@@ -18,32 +18,32 @@ Or you can manually install and configure proxy server using the steps below.
|
||||
|
||||
```sh
|
||||
# Debian / Ubuntu - X86_64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita_3.17.0_amd64.deb
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita_3.17.1_amd64.deb
|
||||
|
||||
# Debian / Ubuntu - ARM 64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita_3.17.0_arm64.deb
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita_3.17.1_arm64.deb
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - X86_64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita-3.17.0-1.x86_64.rpm
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita-3.17.1-1.x86_64.rpm
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - ARM 64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita-3.17.0-1.aarch64.rpm
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita-3.17.1-1.aarch64.rpm
|
||||
```
|
||||
|
||||
## Install mita package
|
||||
|
||||
```sh
|
||||
# Debian / Ubuntu - X86_64
|
||||
sudo dpkg -i mita_3.17.0_amd64.deb
|
||||
sudo dpkg -i mita_3.17.1_amd64.deb
|
||||
|
||||
# Debian / Ubuntu - ARM 64
|
||||
sudo dpkg -i mita_3.17.0_arm64.deb
|
||||
sudo dpkg -i mita_3.17.1_arm64.deb
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - X86_64
|
||||
sudo rpm -Uvh --force mita-3.17.0-1.x86_64.rpm
|
||||
sudo rpm -Uvh --force mita-3.17.1-1.x86_64.rpm
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - ARM 64
|
||||
sudo rpm -Uvh --force mita-3.17.0-1.aarch64.rpm
|
||||
sudo rpm -Uvh --force mita-3.17.1-1.aarch64.rpm
|
||||
```
|
||||
|
||||
Those instructions can also be used to upgrade the version of mita software package.
|
||||
|
@@ -18,32 +18,32 @@ sudo python3 setup.py --lang=zh
|
||||
|
||||
```sh
|
||||
# Debian / Ubuntu - X86_64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita_3.17.0_amd64.deb
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita_3.17.1_amd64.deb
|
||||
|
||||
# Debian / Ubuntu - ARM 64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita_3.17.0_arm64.deb
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita_3.17.1_arm64.deb
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - X86_64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita-3.17.0-1.x86_64.rpm
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita-3.17.1-1.x86_64.rpm
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - ARM 64
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.0/mita-3.17.0-1.aarch64.rpm
|
||||
curl -LSO https://github.com/enfein/mieru/releases/download/v3.17.1/mita-3.17.1-1.aarch64.rpm
|
||||
```
|
||||
|
||||
## 安装 mita 软件包
|
||||
|
||||
```sh
|
||||
# Debian / Ubuntu - X86_64
|
||||
sudo dpkg -i mita_3.17.0_amd64.deb
|
||||
sudo dpkg -i mita_3.17.1_amd64.deb
|
||||
|
||||
# Debian / Ubuntu - ARM 64
|
||||
sudo dpkg -i mita_3.17.0_arm64.deb
|
||||
sudo dpkg -i mita_3.17.1_arm64.deb
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - X86_64
|
||||
sudo rpm -Uvh --force mita-3.17.0-1.x86_64.rpm
|
||||
sudo rpm -Uvh --force mita-3.17.1-1.x86_64.rpm
|
||||
|
||||
# RedHat / CentOS / Rocky Linux - ARM 64
|
||||
sudo rpm -Uvh --force mita-3.17.0-1.aarch64.rpm
|
||||
sudo rpm -Uvh --force mita-3.17.1-1.aarch64.rpm
|
||||
```
|
||||
|
||||
上述指令也可以用来升级 mita 软件包的版本。
|
||||
|
@@ -817,19 +817,20 @@ var serverGetUsersFunc = func(_ []string) error {
|
||||
|
||||
// Collect download and upload metrics of this user.
|
||||
var down, up *metrics.Counter
|
||||
var err error
|
||||
for _, metric := range userWithMetrics.GetMetrics() {
|
||||
switch metric.GetName() {
|
||||
case metrics.UserMetricDownloadBytes:
|
||||
down, err = metrics.NewCounterFromMetricPB(metric)
|
||||
downMetric, err := metrics.FromMetricPB(metric)
|
||||
if err != nil {
|
||||
return fmt.Errorf("metrics.NewCounterFromMetricPB() failed: %w", err)
|
||||
return fmt.Errorf("metrics.FromMetricPB() failed: %w", err)
|
||||
}
|
||||
down = downMetric.(*metrics.Counter)
|
||||
case metrics.UserMetricUploadBytes:
|
||||
up, err = metrics.NewCounterFromMetricPB(metric)
|
||||
upMetric, err := metrics.FromMetricPB(metric)
|
||||
if err != nil {
|
||||
return fmt.Errorf("metrics.NewCounterFromMetricPB() failed: %w", err)
|
||||
return fmt.Errorf("metrics.FromMetricPB() failed: %w", err)
|
||||
}
|
||||
up = upMetric.(*metrics.Counter)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,19 +903,20 @@ var serverGetQuotasFunc = func(_ []string) error {
|
||||
|
||||
// Collect download and upload metrics of this user.
|
||||
var down, up *metrics.Counter
|
||||
var err error
|
||||
for _, metric := range userWithMetrics.GetMetrics() {
|
||||
switch metric.GetName() {
|
||||
case metrics.UserMetricDownloadBytes:
|
||||
down, err = metrics.NewCounterFromMetricPB(metric)
|
||||
downMetric, err := metrics.FromMetricPB(metric)
|
||||
if err != nil {
|
||||
return fmt.Errorf("metrics.NewCounterFromMetricPB() failed: %w", err)
|
||||
return fmt.Errorf("metrics.FromMetricPB() failed: %w", err)
|
||||
}
|
||||
down = downMetric.(*metrics.Counter)
|
||||
case metrics.UserMetricUploadBytes:
|
||||
up, err = metrics.NewCounterFromMetricPB(metric)
|
||||
upMetric, err := metrics.FromMetricPB(metric)
|
||||
if err != nil {
|
||||
return fmt.Errorf("metrics.NewCounterFromMetricPB() failed: %w", err)
|
||||
return fmt.Errorf("metrics.FromMetricPB() failed: %w", err)
|
||||
}
|
||||
up = upMetric.(*metrics.Counter)
|
||||
}
|
||||
}
|
||||
if down == nil || up == nil {
|
||||
|
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
rollUpInterval = 1024
|
||||
rollUpInterval = 1000
|
||||
rollUpToSecond = 2 * time.Second
|
||||
rollUpSecondToMinute = 120 * time.Second
|
||||
rollUpMinuteToHour = 120 * time.Minute
|
||||
|
@@ -211,6 +211,7 @@ func ToMetricPB(src Metric) *pb.Metric {
|
||||
if src.Type() == COUNTER_TIME_SERIES {
|
||||
counter := src.(*Counter)
|
||||
counter.mu.Lock()
|
||||
dst.Value = proto.Int64(counter.value) // Make sure value matches history.
|
||||
dst.History = make([]*pb.History, len(counter.history))
|
||||
copy(dst.History, counter.history)
|
||||
counter.mu.Unlock()
|
||||
@@ -218,20 +219,32 @@ func ToMetricPB(src Metric) *pb.Metric {
|
||||
return dst
|
||||
}
|
||||
|
||||
// NewCounterFromMetricPB creates a counter metric from the protobuf.
|
||||
func NewCounterFromMetricPB(src *pb.Metric) (*Counter, error) {
|
||||
if src.GetType() != pb.MetricType_COUNTER && src.GetType() != pb.MetricType_COUNTER_TIME_SERIES {
|
||||
return nil, fmt.Errorf("type %v can't be converted to Counter", src.GetType().String())
|
||||
// FromMetricPB creates a metric from the protobuf.
|
||||
func FromMetricPB(src *pb.Metric) (Metric, error) {
|
||||
if src.GetType() != pb.MetricType_COUNTER && src.GetType() != pb.MetricType_COUNTER_TIME_SERIES && src.GetType() != pb.MetricType_GAUGE {
|
||||
return nil, fmt.Errorf("metric type %v is invalid", src.GetType().String())
|
||||
}
|
||||
|
||||
c := &Counter{
|
||||
name: src.GetName(),
|
||||
var m Metric
|
||||
switch src.GetType() {
|
||||
case pb.MetricType_COUNTER:
|
||||
m = &Counter{
|
||||
name: src.GetName(),
|
||||
}
|
||||
loadCounterFromMetricPB(m.(*Counter), src)
|
||||
case pb.MetricType_COUNTER_TIME_SERIES:
|
||||
m = &Counter{
|
||||
name: src.GetName(),
|
||||
timeSeries: true,
|
||||
}
|
||||
loadCounterFromMetricPB(m.(*Counter), src)
|
||||
case pb.MetricType_GAUGE:
|
||||
m = &Gauge{
|
||||
name: src.GetName(),
|
||||
}
|
||||
loadGaugeFromMetricPB(m.(*Gauge), src)
|
||||
}
|
||||
if src.GetType() == pb.MetricType_COUNTER_TIME_SERIES {
|
||||
c.timeSeries = true
|
||||
}
|
||||
loadCounterFromMetricPB(c, src)
|
||||
return c, nil
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// LogMetricsNow writes the current metrics to log.
|
||||
@@ -269,7 +282,7 @@ func logMetricsLoop() {
|
||||
}
|
||||
|
||||
func loadCounterFromMetricPB(dst *Counter, src *pb.Metric) {
|
||||
// Verify the name and type matches.
|
||||
// Verify the type matches.
|
||||
if src.GetName() != dst.Name() {
|
||||
return
|
||||
}
|
||||
@@ -280,3 +293,12 @@ func loadCounterFromMetricPB(dst *Counter, src *pb.Metric) {
|
||||
dst.history = src.GetHistory()
|
||||
}
|
||||
}
|
||||
|
||||
func loadGaugeFromMetricPB(dst *Gauge, src *pb.Metric) {
|
||||
// Verify the type matches.
|
||||
if src.GetName() != dst.Name() {
|
||||
return
|
||||
}
|
||||
|
||||
dst.Store(src.GetValue())
|
||||
}
|
||||
|
@@ -17,8 +17,10 @@ package metrics
|
||||
|
||||
import (
|
||||
"errors"
|
||||
mrand "math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -62,24 +64,106 @@ func TestMetricsDump(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestToMetricPBConcurrent(t *testing.T) {
|
||||
counter := &Counter{name: "counter", timeSeries: true}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
stop := make(chan struct{})
|
||||
|
||||
// Goroutine to continuously add history.
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
currentTime := time.Now()
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
return
|
||||
default:
|
||||
// Add a small random duration to the time to ensure it's always increasing.
|
||||
currentTime = currentTime.Add(time.Duration(mrand.Intn(100)+1) * time.Millisecond)
|
||||
counter.addWithTime(int64(mrand.Intn(100)), currentTime)
|
||||
// Run the for loop enough times to trigger rollup.
|
||||
time.Sleep(time.Microsecond)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Goroutine to verify the counter value matches the sum of history.
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
return
|
||||
default:
|
||||
p := ToMetricPB(counter)
|
||||
var sum int64
|
||||
for _, h := range p.GetHistory() {
|
||||
sum += h.GetDelta()
|
||||
}
|
||||
if p.GetValue() != sum {
|
||||
t.Errorf("sum of history deltas (%d) does not match counter value (%d)", sum, p.GetValue())
|
||||
}
|
||||
time.Sleep(time.Duration(mrand.Intn(100)) * time.Microsecond)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
time.Sleep(time.Second)
|
||||
close(stop)
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func TestMetricPBConvertion(t *testing.T) {
|
||||
p := &pb.Metric{
|
||||
Name: proto.String("counter"),
|
||||
Type: pb.MetricType_COUNTER_TIME_SERIES.Enum(),
|
||||
Value: proto.Int64(100),
|
||||
History: []*pb.History{
|
||||
{
|
||||
TimeUnixMilli: proto.Int64(time.Now().UnixMilli()),
|
||||
Delta: proto.Int64(100),
|
||||
testCases := []struct {
|
||||
name string
|
||||
metricPB *pb.Metric
|
||||
}{
|
||||
{
|
||||
name: "CounterTimeSeries",
|
||||
metricPB: &pb.Metric{
|
||||
Name: proto.String("counter_ts"),
|
||||
Type: pb.MetricType_COUNTER_TIME_SERIES.Enum(),
|
||||
Value: proto.Int64(100),
|
||||
History: []*pb.History{
|
||||
{
|
||||
TimeUnixMilli: proto.Int64(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC).UnixMilli()),
|
||||
Delta: proto.Int64(100),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Counter",
|
||||
metricPB: &pb.Metric{
|
||||
Name: proto.String("counter"),
|
||||
Type: pb.MetricType_COUNTER.Enum(),
|
||||
Value: proto.Int64(200),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Gauge",
|
||||
metricPB: &pb.Metric{
|
||||
Name: proto.String("gauge"),
|
||||
Type: pb.MetricType_GAUGE.Enum(),
|
||||
Value: proto.Int64(300),
|
||||
},
|
||||
},
|
||||
}
|
||||
c, err := NewCounterFromMetricPB(p)
|
||||
if err != nil {
|
||||
t.Fatalf("NewCounterFromMetricPB() failed: %v", err)
|
||||
}
|
||||
p2 := ToMetricPB(c)
|
||||
if !proto.Equal(p, p2) {
|
||||
t.Errorf("metric protobuf doesn't match")
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
m, err := FromMetricPB(tc.metricPB)
|
||||
if err != nil {
|
||||
t.Fatalf("FromMetricPB() failed: %v", err)
|
||||
}
|
||||
p2 := ToMetricPB(m)
|
||||
|
||||
if !proto.Equal(tc.metricPB, p2) {
|
||||
t.Errorf("metric protobuf doesn't match.\nwant: %v\ngot: %v", tc.metricPB, p2)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -16,5 +16,5 @@
|
||||
package version
|
||||
|
||||
const (
|
||||
AppVersion = "3.17.0"
|
||||
AppVersion = "3.17.1"
|
||||
)
|
||||
|
Reference in New Issue
Block a user