Skip to content

Commit

Permalink
v3.8.4 release
Browse files Browse the repository at this point in the history
1. Optimize mihomo executable file size.
  • Loading branch information
enfein committed Dec 9, 2024
1 parent dcb3f8a commit 9f6a7bb
Show file tree
Hide file tree
Showing 20 changed files with 159 additions and 88 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/mihomo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'mihomo test'
on: [workflow_dispatch]
jobs:
run-test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out mieru repository code
uses: actions/checkout@v4
with:
path: mieru
- name: Check out mihomo repository code
uses: actions/checkout@v4
with:
ref: Alpha
path: mihomo
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Update mieru reference
run: echo "replace github.com/enfein/mieru/v3 => ../mieru" >> go.mod
- name: Build mihomo
run: make linux-amd64-compatible
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.8.3"
VERSION="3.8.4"

# Build binaries and installation packages.
.PHONY: build
Expand Down
9 changes: 6 additions & 3 deletions apis/client/mieru.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
apicommon "github.com/enfein/mieru/v3/apis/common"
"github.com/enfein/mieru/v3/apis/constant"
"github.com/enfein/mieru/v3/apis/model"
"github.com/enfein/mieru/v3/pkg/appctl"
"github.com/enfein/mieru/v3/pkg/appctl/appctlcommon"
"github.com/enfein/mieru/v3/pkg/appctl/appctlpb"
"github.com/enfein/mieru/v3/pkg/cipher"
"github.com/enfein/mieru/v3/pkg/common"
Expand All @@ -38,6 +38,9 @@ import (
"github.com/enfein/mieru/v3/pkg/stderror"
)

// This package should not depends on github.com/enfein/mieru/v3/pkg/appctl,
// which introduces gRPC dependency.

// mieruClient is the official implementation of mieru client APIs.
type mieruClient struct {
initTask sync.Once
Expand Down Expand Up @@ -80,7 +83,7 @@ func (mc *mieruClient) Store(config *ClientConfig) error {
if mc.running {
return ErrStoreClientConfigAfterStart
}
if err := appctl.ValidateClientConfigSingleProfile(config.Profile); err != nil {
if err := appctlcommon.ValidateClientConfigSingleProfile(config.Profile); err != nil {
return fmt.Errorf("%w: %s", ErrInvalidConfigConfig, err.Error())
}
mc.config = config
Expand Down Expand Up @@ -168,7 +171,7 @@ func (mc *mieruClient) Start() error {
return fmt.Errorf(stderror.ParseIPFailed)
}
}
portBindings, err := appctl.FlatPortBindings(serverInfo.GetPortBindings())
portBindings, err := appctlcommon.FlatPortBindings(serverInfo.GetPortBindings())
if err != nil {
return fmt.Errorf(stderror.InvalidPortBindingsErr, err)
}
Expand Down
2 changes: 1 addition & 1 deletion build/package/mieru/amd64/debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: mieru
Version: 3.8.3
Version: 3.8.4
Section: net
Priority: optional
Architecture: amd64
Expand Down
2 changes: 1 addition & 1 deletion build/package/mieru/amd64/rpm/mieru.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mieru
Version: 3.8.3
Version: 3.8.4
Release: 1%{?dist}
Summary: Mieru proxy client
License: GPLv3+
Expand Down
2 changes: 1 addition & 1 deletion build/package/mieru/arm64/debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: mieru
Version: 3.8.3
Version: 3.8.4
Section: net
Priority: optional
Architecture: arm64
Expand Down
2 changes: 1 addition & 1 deletion build/package/mieru/arm64/rpm/mieru.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mieru
Version: 3.8.3
Version: 3.8.4
Release: 1%{?dist}
Summary: Mieru proxy client
License: GPLv3+
Expand Down
2 changes: 1 addition & 1 deletion build/package/mita/amd64/debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: mita
Version: 3.8.3
Version: 3.8.4
Section: net
Priority: optional
Architecture: amd64
Expand Down
2 changes: 1 addition & 1 deletion build/package/mita/amd64/rpm/mita.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mita
Version: 3.8.3
Version: 3.8.4
Release: 1%{?dist}
Summary: Mieru proxy server
License: GPLv3+
Expand Down
2 changes: 1 addition & 1 deletion build/package/mita/arm64/debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: mita
Version: 3.8.3
Version: 3.8.4
Section: net
Priority: optional
Architecture: arm64
Expand Down
2 changes: 1 addition & 1 deletion build/package/mita/arm64/rpm/mita.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mita
Version: 3.8.3
Version: 3.8.4
Release: 1%{?dist}
Summary: Mieru proxy server
License: GPLv3+
Expand Down
16 changes: 8 additions & 8 deletions docs/server-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ Before installation and configuration, connect to the server via SSH and then ex

```sh
# Debian / Ubuntu - X86_64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita_3.8.3_amd64.deb
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita_3.8.4_amd64.deb

# Debian / Ubuntu - ARM 64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita_3.8.3_arm64.deb
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita_3.8.4_arm64.deb

# RedHat / CentOS / Rocky Linux - X86_64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita-3.8.3-1.x86_64.rpm
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita-3.8.4-1.x86_64.rpm

# RedHat / CentOS / Rocky Linux - ARM 64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita-3.8.3-1.aarch64.rpm
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita-3.8.4-1.aarch64.rpm
```

## Install mita package

```sh
# Debian / Ubuntu - X86_64
sudo dpkg -i mita_3.8.3_amd64.deb
sudo dpkg -i mita_3.8.4_amd64.deb

# Debian / Ubuntu - ARM 64
sudo dpkg -i mita_3.8.3_arm64.deb
sudo dpkg -i mita_3.8.4_arm64.deb

# RedHat / CentOS / Rocky Linux - X86_64
sudo rpm -Uvh --force mita-3.8.3-1.x86_64.rpm
sudo rpm -Uvh --force mita-3.8.4-1.x86_64.rpm

# RedHat / CentOS / Rocky Linux - ARM 64
sudo rpm -Uvh --force mita-3.8.3-1.aarch64.rpm
sudo rpm -Uvh --force mita-3.8.4-1.aarch64.rpm
```

Those instructions can also be used to upgrade the version of mita software package.
Expand Down
16 changes: 8 additions & 8 deletions docs/server-install.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@

```sh
# Debian / Ubuntu - X86_64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita_3.8.3_amd64.deb
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita_3.8.4_amd64.deb

# Debian / Ubuntu - ARM 64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita_3.8.3_arm64.deb
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita_3.8.4_arm64.deb

# RedHat / CentOS / Rocky Linux - X86_64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita-3.8.3-1.x86_64.rpm
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita-3.8.4-1.x86_64.rpm

# RedHat / CentOS / Rocky Linux - ARM 64
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.3/mita-3.8.3-1.aarch64.rpm
curl -LSO https://github.com/enfein/mieru/releases/download/v3.8.4/mita-3.8.4-1.aarch64.rpm
```

## 安装 mita 软件包

```sh
# Debian / Ubuntu - X86_64
sudo dpkg -i mita_3.8.3_amd64.deb
sudo dpkg -i mita_3.8.4_amd64.deb

# Debian / Ubuntu - ARM 64
sudo dpkg -i mita_3.8.3_arm64.deb
sudo dpkg -i mita_3.8.4_arm64.deb

# RedHat / CentOS / Rocky Linux - X86_64
sudo rpm -Uvh --force mita-3.8.3-1.x86_64.rpm
sudo rpm -Uvh --force mita-3.8.4-1.x86_64.rpm

# RedHat / CentOS / Rocky Linux - ARM 64
sudo rpm -Uvh --force mita-3.8.3-1.aarch64.rpm
sudo rpm -Uvh --force mita-3.8.4-1.aarch64.rpm
```

上述指令也可以用来升级 mita 软件包的版本。
Expand Down
76 changes: 76 additions & 0 deletions pkg/appctl/appctlcommon/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (C) 2024 mieru authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package appctlcommon

import (
"fmt"
"net"

pb "github.com/enfein/mieru/v3/pkg/appctl/appctlpb"
)

// ValidateClientConfigSingleProfile validates
// a single client config profile.
//
// It validates
// 1. profile name is not empty
// 2. user name is not empty
// 3. user has either a password or a hashed password
// 4. user has no quota
// 5. it has at least 1 server, and for each server
// 5.1. the server has either IP address or domain name
// 5.2. if set, server's IP address is parsable
// 5.3. the server has at least 1 port binding, and all port bindings are valid
// 6. if set, MTU is valid
func ValidateClientConfigSingleProfile(profile *pb.ClientProfile) error {
name := profile.GetProfileName()
if name == "" {
return fmt.Errorf("profile name is not set")
}
user := profile.GetUser()
if user.GetName() == "" {
return fmt.Errorf("user name is not set")
}
if user.GetPassword() == "" && user.GetHashedPassword() == "" {
return fmt.Errorf("user password is not set")
}
if len(user.GetQuotas()) != 0 {
return fmt.Errorf("user quota is not supported by proxy client")
}
servers := profile.GetServers()
if len(servers) == 0 {
return fmt.Errorf("servers are not set")
}
for _, server := range servers {
if server.GetIpAddress() == "" && server.GetDomainName() == "" {
return fmt.Errorf("neither server IP address nor domain name is set")
}
if server.GetIpAddress() != "" && net.ParseIP(server.GetIpAddress()) == nil {
return fmt.Errorf("failed to parse IP address %q", server.GetIpAddress())
}
portBindings := server.GetPortBindings()
if len(portBindings) == 0 {
return fmt.Errorf("server port binding is not set")
}
if _, err := FlatPortBindings(portBindings); err != nil {
return err
}
}
if profile.GetMtu() != 0 && (profile.GetMtu() < 1280 || profile.GetMtu() > 1500) {
return fmt.Errorf("MTU value %d is out of range, valid range is [1280, 1500]", profile.GetMtu())
}
return nil
}
19 changes: 19 additions & 0 deletions pkg/appctl/appctlcommon/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2024 mieru authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// Package appctlcommon contains selected functions
// that don't have gRPC dependency. This helps to remove gRPC dependency
// from API consumers.
package appctlcommon
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package appctl
package appctlcommon

import (
"fmt"
Expand Down
57 changes: 2 additions & 55 deletions pkg/appctl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (
"context"
"fmt"
"io"
"net"
"os"
"path/filepath"
"sort"
"strconv"
"sync"
"sync/atomic"

"github.com/enfein/mieru/v3/pkg/appctl/appctlcommon"
"github.com/enfein/mieru/v3/pkg/appctl/appctlgrpc"
pb "github.com/enfein/mieru/v3/pkg/appctl/appctlpb"
"github.com/enfein/mieru/v3/pkg/common"
Expand Down Expand Up @@ -358,7 +358,7 @@ func DeleteClientConfigProfile(profileName string) error {
// 3. for each socks5 authentication, the user and password are not empty
func ValidateClientConfigPatch(patch *pb.ClientConfig) error {
for _, profile := range patch.GetProfiles() {
if err := ValidateClientConfigSingleProfile(profile); err != nil {
if err := appctlcommon.ValidateClientConfigSingleProfile(profile); err != nil {
return err
}
}
Expand All @@ -373,59 +373,6 @@ func ValidateClientConfigPatch(patch *pb.ClientConfig) error {
return nil
}

// ValidateClientConfigSingleProfile validates
// a single client config profile.
//
// It validates
// 1. profile name is not empty
// 2. user name is not empty
// 3. user has either a password or a hashed password
// 4. user has no quota
// 5. it has at least 1 server, and for each server
// 5.1. the server has either IP address or domain name
// 5.2. if set, server's IP address is parsable
// 5.3. the server has at least 1 port binding, and all port bindings are valid
// 6. if set, MTU is valid
func ValidateClientConfigSingleProfile(profile *pb.ClientProfile) error {
name := profile.GetProfileName()
if name == "" {
return fmt.Errorf("profile name is not set")
}
user := profile.GetUser()
if user.GetName() == "" {
return fmt.Errorf("user name is not set")
}
if user.GetPassword() == "" && user.GetHashedPassword() == "" {
return fmt.Errorf("user password is not set")
}
if len(user.GetQuotas()) != 0 {
return fmt.Errorf("user quota is not supported by proxy client")
}
servers := profile.GetServers()
if len(servers) == 0 {
return fmt.Errorf("servers are not set")
}
for _, server := range servers {
if server.GetIpAddress() == "" && server.GetDomainName() == "" {
return fmt.Errorf("neither server IP address nor domain name is set")
}
if server.GetIpAddress() != "" && net.ParseIP(server.GetIpAddress()) == nil {
return fmt.Errorf("failed to parse IP address %q", server.GetIpAddress())
}
portBindings := server.GetPortBindings()
if len(portBindings) == 0 {
return fmt.Errorf("server port binding is not set")
}
if _, err := FlatPortBindings(portBindings); err != nil {
return err
}
}
if profile.GetMtu() != 0 && (profile.GetMtu() < 1280 || profile.GetMtu() > 1500) {
return fmt.Errorf("MTU value %d is out of range, valid range is [1280, 1500]", profile.GetMtu())
}
return nil
}

// ValidateFullClientConfig validates the full client config.
//
// In addition to ValidateClientConfigPatch, it also validates:
Expand Down
Loading

0 comments on commit 9f6a7bb

Please sign in to comment.