Update On Thu Sep 25 20:42:16 CEST 2025

This commit is contained in:
github-action[bot]
2025-09-25 20:42:17 +02:00
parent c419341558
commit f39050f25e
98 changed files with 2493 additions and 1892 deletions

View File

@@ -75,16 +75,16 @@ func (mc *mieruClient) Store(config *ClientConfig) error {
mc.mu.Lock()
defer mc.mu.Unlock()
if config == nil {
return fmt.Errorf("%w: client config is nil", ErrInvalidConfigConfig)
return fmt.Errorf("%w: client config is nil", ErrInvalidClientConfig)
}
if config.Profile == nil {
return fmt.Errorf("%w: client config profile is nil", ErrInvalidConfigConfig)
return fmt.Errorf("%w: client config profile is nil", ErrInvalidClientConfig)
}
if mc.running {
return ErrStoreClientConfigAfterStart
}
if err := appctlcommon.ValidateClientConfigSingleProfile(config.Profile); err != nil {
return fmt.Errorf("%w: %s", ErrInvalidConfigConfig, err.Error())
return fmt.Errorf("%w: %s", ErrInvalidClientConfig, err.Error())
}
mc.config = config
return nil

View File

@@ -26,12 +26,12 @@ import (
var (
ErrNoClientConfig = errors.New("no client config")
ErrInvalidConfigConfig = errors.New("invalid client config")
ErrInvalidClientConfig = errors.New("invalid client config")
ErrClientIsNotRunning = errors.New("client is not running")
ErrStoreClientConfigAfterStart = errors.New("can't store client config after start")
)
// Client contains methods supported by a mieru client.
// Client contains methods supported by a proxy client.
type Client interface {
ClientConfigurationService
ClientLifecycleService

18
mieru/apis/server/doc.go Normal file
View File

@@ -0,0 +1,18 @@
// Copyright (C) 2025 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 server provides mieru server APIs for third party applications
// to integrate mieru protocol.
package server

View File

@@ -0,0 +1,73 @@
// Copyright (C) 2025 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 server
import (
"errors"
"github.com/enfein/mieru/v3/pkg/appctl/appctlpb"
)
var (
ErrNoServerConfig = errors.New("no server config")
ErrInvalidServerConfig = errors.New("invalid server config")
ErrServerIsNotRunning = errors.New("server is not running")
ErrStoreServerConfigAfterStart = errors.New("can't store server config after start")
)
// Server contains methods supported by a proxy server.
type Server interface {
ServerConfigurationService
ServerLifecycleService
ServerNetworkService
}
// ServerConfigurationService contains methods to manage proxy server configuration.
type ServerConfigurationService interface {
// Load returns the server config.
// It returns ErrNoServerConfig if server config is never stored.
Load() (*ServerConfig, error)
// Store saves the server config.
// It returns wrapped ErrInvalidServerConfig error
// if the provided server config is invalid.
// It returns ErrStoreServerConfigAfterStart error
// if it is called after start.
Store(*ServerConfig) error
}
// ServerLifecycleService contains methods to manage proxy server lifecycle.
type ServerLifecycleService interface {
// Start activates the server with the stored configuration.
// Calling Start function more than once has undefined behavior.
Start() error
// Stop deactivates the server.
// Established network connections are NOT terminated.
// After stop, the server can't be reused.
Stop() error
// IsRunning returns true if the server has been started
// and has not been stopped.
IsRunning() bool
}
type ServerNetworkService interface{}
// ServerConfig stores proxy server configuration.
type ServerConfig struct {
Config *appctlpb.ServerConfig
}