Skip to content

Commit

Permalink
Check stderr of tcset. v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 6, 2023
1 parent 0875c4c commit e552289
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"
)

const version = "1.0.2"
const version = "1.0.3"

func main() {
ctx := logger.WithContext(context.Background())
Expand Down
9 changes: 7 additions & 2 deletions tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ func TcReset(ctx context.Context, w http.ResponseWriter, r *http.Request) error

if !isDarwin {
args := []string{"--all", iface}
if err := exec.CommandContext(ctx, "tcdel", args...).Run(); err != nil {
if b, err := exec.CommandContext(ctx, "tcdel", args...).CombinedOutput(); err != nil {
return errors.Wrapf(err, "tcdel %v", strings.Join(args, " "))
} else if len(b) > 0 {
return errors.Errorf("tcdel %v, %v", strings.Join(args, " "), string(b))
}
logger.Tf(ctx, "tcdel %v", strings.Join(args, " "))
}
Expand Down Expand Up @@ -401,9 +403,12 @@ func (v *NetworkOptions) Execute(ctx context.Context) error {
}

args = append(args, v.iface)
if err := exec.CommandContext(ctx, "tcset", args...).Run(); err != nil {
if b, err := exec.CommandContext(ctx, "tcset", args...).CombinedOutput(); err != nil {
return errors.Wrapf(err, "tcset %v", strings.Join(args, " "))
} else if len(b) > 0 {
return errors.Errorf("tcset %v, %v", strings.Join(args, " "), string(b))
}

logger.Tf(ctx, "tcset %v", strings.Join(args, " "))
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions ui/src/components/NetFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export default function NetFilter({onChange, gIfaces}) {
<Col xs='auto'>
<Form.Group className="mb-3">
<Form.Label><b>流量方向</b></Form.Label>
<Form.Text> * 上行或下行</Form.Text>
<Form.Text> * 流入或流出</Form.Text>
<InputGroup hasValidation>
<Form.Select required defaultValue={direction} onChange={(e) => setDirection(e.target.value)}>
<option value="">--请选择--</option>
<option value="incoming">发送到服务器(上行)</option>
<option value="outgoing">从服务器接收(下行)</option>
<option value="incoming">流入(incoming), 发数据到这个设备</option>
<option value="outgoing">流出(outgoing), 从该设备接收数据</option>
</Form.Select>
<Form.Control.Feedback type='invalid' tooltip>请选择客户端类型</Form.Control.Feedback>
</InputGroup>
Expand All @@ -73,9 +73,9 @@ export default function NetFilter({onChange, gIfaces}) {
<InputGroup hasValidation>
<Form.Select required defaultValue={identifyKey} onChange={updateIdentify}>
<option value="">--请选择--</option>
<option value="serverPort">按服务器端口</option>n>
<option value="clientIp">按客户端IP</option>n>
<option value="clientPort">按客户端端口</option>
<option value="serverPort">按本设备端口</option>n>
<option value="clientIp">按对方设备IP</option>n>
<option value="clientPort">按对方设备端口</option>
<option value="all">匹配所有</option>
</Form.Select>
<Form.Control.Feedback type='invalid' tooltip>请选择弱网标识</Form.Control.Feedback>
Expand Down
14 changes: 8 additions & 6 deletions ui/src/pages/SingleStategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ function SingleStategySetting() {
</Row>
<Row>
<Col xs='auto'>
<Button variant="primary" type="button" onClick={setupNetwork} disabled={executing}>
设置网络
</Button> &nbsp;
<Button variant="primary" type="button" onClick={resetNetwork} disabled={executing}>
重置网络
</Button>
<TcErrorBoundary>
<Button variant="primary" type="button" onClick={setupNetwork} disabled={executing}>
设置网络
</Button> &nbsp;
<Button variant="primary" type="button" onClick={resetNetwork} disabled={executing}>
重置网络
</Button>
</TcErrorBoundary>
</Col>
</Row>
<Row>
Expand Down

0 comments on commit e552289

Please sign in to comment.