feat: terminal api

This commit is contained in:
naiba
2024-10-22 22:01:01 +08:00
parent 387da11f1b
commit f99edfd7bd
7 changed files with 121 additions and 478 deletions

View File

@@ -47,36 +47,6 @@ const (
ConfigCoverIgnoreAll
)
type AgentConfig struct {
HardDrivePartitionAllowlist []string
NICAllowlist map[string]bool
v *viper.Viper
}
// Read 从给定的文件目录加载配置文件
func (c *AgentConfig) Read(path string) error {
c.v = viper.New()
c.v.SetConfigFile(path)
err := c.v.ReadInConfig()
if err != nil {
return err
}
err = c.v.Unmarshal(c)
if err != nil {
return err
}
return nil
}
func (c *AgentConfig) Save() error {
data, err := yaml.Marshal(c)
if err != nil {
return err
}
return os.WriteFile(c.v.ConfigFileUsed(), data, 0600)
}
// Config 站点配置
type Config struct {
Debug bool // debug模式开关

12
model/terminal_api.go Normal file
View File

@@ -0,0 +1,12 @@
package model
type TerminalForm struct {
Protocol string `json:"protocol,omitempty"`
ServerID uint64 `json:"server_id,omitempty"`
}
type CreateTerminalResponse struct {
SessionID string `json:"session_id,omitempty"`
ServerID uint64 `json:"server_id,omitempty"`
ServerName string `json:"server_name,omitempty"`
}