-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
574 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
backend/terminal/src/main/java/com/kkbpro/terminal/controller/AdvanceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.kkbpro.terminal.controller; | ||
|
||
import com.kkbpro.terminal.constants.enums.FileBlockStateEnum; | ||
import com.kkbpro.terminal.consumer.WebSocketServer; | ||
import com.kkbpro.terminal.pojo.dto.CooperateInfo; | ||
import com.kkbpro.terminal.result.Result; | ||
import com.kkbpro.terminal.utils.AesUtil; | ||
import com.kkbpro.terminal.utils.StringUtil; | ||
import net.schmizz.sshj.SSHClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* 高级功能接口类 | ||
*/ | ||
@RestController | ||
@RequestMapping("/api") | ||
public class AdvanceController { | ||
|
||
public static final String COOPERATE_SECRET_KEY = "o4D1fYuVp2js9xKX"; | ||
|
||
/** | ||
* 获取协作id | ||
*/ | ||
@GetMapping("/cooperate") | ||
public Result getCooperateId(String sshKey, Boolean readOnly, Integer maxHeadCount) throws Exception { | ||
String errorMsg = "协作Key生成失败"; | ||
String successMsg = "协作Key生成成功"; | ||
|
||
SSHClient ssh = WebSocketServer.sshClientMap.get(sshKey); | ||
WebSocketServer webSocketServer = WebSocketServer.webSocketServerMap.get(sshKey); | ||
if(ssh == null || webSocketServer == null) { | ||
return Result.error(FileBlockStateEnum.SSH_NOT_EXIST.getState(),"连接断开," + errorMsg); | ||
} | ||
if(webSocketServer.getCooperateInfo() != null) | ||
return Result.error(errorMsg); | ||
|
||
CooperateInfo cooperateInfo = new CooperateInfo(); | ||
cooperateInfo.setReadOnly(readOnly); | ||
cooperateInfo.setMaxHeadCount(maxHeadCount); | ||
webSocketServer.setCooperateInfo(cooperateInfo); | ||
|
||
String key = StringUtil.changeBase64Str(AesUtil.aesEncrypt(sshKey, COOPERATE_SECRET_KEY)); | ||
|
||
return Result.success(successMsg, key); | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
backend/terminal/src/main/java/com/kkbpro/terminal/pojo/dto/CooperateInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.kkbpro.terminal.pojo.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* 协作相关 | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CooperateInfo { | ||
|
||
private Boolean readOnly; | ||
|
||
private Integer maxHeadCount; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,6 @@ public class EnvInfo { | |
|
||
private String lang = "en"; | ||
|
||
private String cooperateKey = null; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.