Просмотр исходного кода

删除 oss-store 中 OssProperties 的 domain, referer 以及 secretKey 字段, 这些字段放到 oss-console 中的 StoreNode 对象里, 由用户自行配置. 同时在 StoreNode 里添加一个 enabled 字段, 只有配置了前述字段才能将 enabled 设置为 true, 表示 oss-store 节点可用

reghao 2 лет назад
Родитель
Сommit
661b01bd70
33 измененных файлов с 337 добавлено и 509 удалено
  1. 0 19
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssServerController.java
  2. 59 0
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssStoreController.java
  3. 2 7
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/StoreNodeController.java
  4. 3 2
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/StoreNodePageController.java
  5. 9 1
      oss-console/src/main/java/cn/reghao/oss/console/app/model/po/StoreNode.java
  6. 2 0
      oss-console/src/main/java/cn/reghao/oss/console/app/model/vo/UploadChannelVo.java
  7. 0 42
      oss-console/src/main/java/cn/reghao/oss/console/app/service/OssService.java
  8. 83 0
      oss-console/src/main/java/cn/reghao/oss/console/app/service/OssStoreService.java
  9. 1 9
      oss-console/src/main/java/cn/reghao/oss/console/config/web/ConsoleAuthInterceptor.java
  10. 2 0
      oss-console/src/main/resources/templates/channel/index.html
  11. 0 62
      oss-console/src/main/resources/templates/node/copy.html
  12. 0 108
      oss-console/src/main/resources/templates/node/deploy/add.html
  13. 0 39
      oss-console/src/main/resources/templates/node/deploy/detail.html
  14. 0 93
      oss-console/src/main/resources/templates/node/deploy/edit.html
  15. 0 51
      oss-console/src/main/resources/templates/node/deploy/index.html
  16. 12 0
      oss-console/src/main/resources/templates/node/edit.html
  17. 6 4
      oss-console/src/main/resources/templates/node/index.html
  18. 45 18
      oss-sdk/src/main/java/cn/reghao/oss/sdk/OssConsoleClient.java
  19. 1 4
      oss-store/bin/oss.yml
  20. 0 6
      oss-store/src/main/java/cn/reghao/oss/store/config/OssProperties.java
  21. 1 1
      oss-store/src/main/java/cn/reghao/oss/store/config/spring/AppLifecycle.java
  22. 7 7
      oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectGetController.java
  23. 5 6
      oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectUploadController.java
  24. 4 4
      oss-store/src/main/java/cn/reghao/oss/store/inerceptor/AccessLogInterceptor.java
  25. 5 5
      oss-store/src/main/java/cn/reghao/oss/store/inerceptor/TokenFilter.java
  26. 5 5
      oss-store/src/main/java/cn/reghao/oss/store/rpc/OssServerServiceImpl.java
  27. 3 3
      oss-store/src/main/java/cn/reghao/oss/store/rpc/SignService.java
  28. 3 3
      oss-store/src/main/java/cn/reghao/oss/store/rpc/disk/FileServiceImpl.java
  29. 2 4
      oss-store/src/main/java/cn/reghao/oss/store/service/GetObjectService.java
  30. 2 3
      oss-store/src/main/java/cn/reghao/oss/store/service/ObjectMultipartUploadService.java
  31. 2 3
      oss-store/src/main/java/cn/reghao/oss/store/service/ObjectNameService.java
  32. 57 0
      oss-store/src/main/java/cn/reghao/oss/store/service/StoreService.java
  33. 16 0
      store-api/src/main/java/cn/reghao/oss/store/api/dto/StoreProperties.java

+ 0 - 19
oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssServerController.java

@@ -2,7 +2,6 @@ package cn.reghao.oss.console.app.controller;
 
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.oss.store.api.dto.DownloadUrl;
-import cn.reghao.oss.store.api.dto.ObjectChannel;
 import cn.reghao.oss.store.api.dto.ObjectInfo;
 import cn.reghao.oss.store.api.dto.ServerInfo;
 import cn.reghao.oss.console.app.service.OssService;
@@ -14,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
-
 /**
  * @author reghao
  * @date 2024-02-23 09:27:36
@@ -37,22 +34,6 @@ public class OssServerController {
         return WebResult.success(serverInfo);
     }
 
-    @ApiOperation(value = "获取某个节点上所有的 UploadChannel")
-    @GetMapping(value = "/channels", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getChannels(@RequestParam("nodeAddr") String nodeAddr) {
-        List<ObjectChannel> list = ossService.getObjectChannels(nodeAddr);
-        return WebResult.success(list);
-    }
-
-    @ApiOperation(value = "获取某个 UploadChannel")
-    @GetMapping(value = "/channel", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getChannel(@RequestParam("createBy") Integer createBy,
-                             @RequestParam("nodeAddr") String nodeAddr,
-                             @RequestParam("channelId") int channelId) {
-        ObjectChannel objectChannel = ossService.getObjectChannel(createBy, nodeAddr, channelId);
-        return WebResult.success(objectChannel);
-    }
-
     @ApiOperation(value = "获取对象信息")
     @GetMapping(value = "/object/info", produces = MediaType.APPLICATION_JSON_VALUE)
     public String getObjectInfo(@RequestParam("objectId") String objectId) {

+ 59 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssStoreController.java

@@ -0,0 +1,59 @@
+package cn.reghao.oss.console.app.controller;
+
+import cn.reghao.jutil.jdk.result.WebResult;
+import cn.reghao.oss.console.app.model.po.StoreNode;
+import cn.reghao.oss.console.app.service.OssStoreService;
+import cn.reghao.oss.store.api.dto.ObjectChannel;
+import cn.reghao.oss.store.api.dto.StoreProperties;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.http.MediaType;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2024-03-01 09:02:37
+ */
+@Api(tags = "oss-store 调用的接口")
+@RestController
+@RequestMapping("/api/oss/store")
+public class OssStoreController {
+    private final OssStoreService ossStoreService;
+
+    public OssStoreController(OssStoreService ossStoreService) {
+        this.ossStoreService = ossStoreService;
+    }
+
+    @ApiOperation(value = "注册存储节点")
+    @PostMapping(value = "/register", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String addStoreNode(@RequestBody @Validated StoreNode storeNode) {
+        ossStoreService.registerNode(storeNode);
+        return WebResult.success();
+    }
+
+    @ApiOperation(value = "获取某个节点上所有的 UploadChannel")
+    @GetMapping(value = "/channels", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getChannels(@RequestParam("nodeAddr") String nodeAddr) {
+        List<ObjectChannel> list = ossStoreService.getObjectChannels(nodeAddr);
+        return WebResult.success(list);
+    }
+
+    @ApiOperation(value = "获取某个 UploadChannel")
+    @GetMapping(value = "/channel", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getChannel(@RequestParam("createBy") Integer createBy,
+                             @RequestParam("nodeAddr") String nodeAddr,
+                             @RequestParam("channelId") int channelId) {
+        ObjectChannel objectChannel = ossStoreService.getObjectChannel(createBy, nodeAddr, channelId);
+        return WebResult.success(objectChannel);
+    }
+
+    @ApiOperation(value = "获取 store 的配置")
+    @GetMapping(value = "/properties", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getStoreProperties(@RequestParam("nodeAddr") String nodeAddr) {
+        StoreProperties storeProperties = ossStoreService.getStoreProperties(nodeAddr);
+        return WebResult.success(storeProperties);
+    }
+}

+ 2 - 7
oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/StoreNodeController.java

@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
 @Slf4j
 @Api(tags = "存储节点数据接口")
 @RestController
-@RequestMapping("/api/oss/store/node")
+@RequestMapping("/api/store/node")
 public class StoreNodeController {
     private final StoreNodeService storeNodeService;
 
@@ -27,12 +27,7 @@ public class StoreNodeController {
         this.storeNodeService = storeNodeService;
     }
 
-    @ApiOperation(value = "添加存储节点")
-    @PostMapping(value = "/register", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String addStoreNode(@RequestBody @Validated StoreNode storeNode) {
-        storeNodeService.add(storeNode);
-        return WebResult.success();
-    }
+
 
     @ApiOperation(value = "设置存储节点的域名")
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)

+ 3 - 2
oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/StoreNodePageController.java

@@ -68,8 +68,9 @@ public class StoreNodePageController {
     }
 
     @ApiOperation(value = "存储节点域名设置页面")
-    @GetMapping("/domain/{id}")
-    public String editAppConfigPage(@PathVariable("id") StoreNode storeNode, Model model) {
+    @GetMapping("/config/{id}")
+    public String editAppConfigPage(@PathVariable("id") Integer nodeId, Model model) {
+        StoreNode storeNode = storeNodeRepository.findById(nodeId).orElse(null);
         model.addAttribute("storeNode", storeNode);
         return "/node/edit";
     }

+ 9 - 1
oss-console/src/main/java/cn/reghao/oss/console/app/model/po/StoreNode.java

@@ -1,5 +1,6 @@
 package cn.reghao.oss.console.app.model.po;
 
+import cn.reghao.jutil.jdk.security.RandomString;
 import cn.reghao.oss.console.util.db.BaseEntity;
 import lombok.Getter;
 import lombok.Setter;
@@ -25,5 +26,12 @@ public class StoreNode extends BaseEntity {
     private Long total;
     private Long avail;
     private String domain;
-    private Integer regionId;
+    private String referer;
+    private String secretKey;
+    private Boolean enabled;
+
+    public StoreNode() {
+        this.secretKey = RandomString.getString(20);
+        this.enabled = false;
+    }
 }

+ 2 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/model/vo/UploadChannelVo.java

@@ -17,6 +17,7 @@ public class UploadChannelVo {
     private String prefix;
     private String maxSize;
     private String fileType;
+    private boolean processFile;
     private String scope;
     private String bindDomain;
 
@@ -27,6 +28,7 @@ public class UploadChannelVo {
         this.prefix = uploadChannel.getPrefix();
         this.maxSize = maxSize;
         this.fileType = ObjectType.getDescByCode(uploadChannel.getFileType());
+        this.processFile = uploadChannel.getProcessFile();
         this.scope = ObjectScope.getByCode(uploadChannel.getScope()).name();
         this.bindDomain = uploadChannel.getBindDomain();
     }

+ 0 - 42
oss-console/src/main/java/cn/reghao/oss/console/app/service/OssService.java

@@ -10,10 +10,6 @@ import cn.reghao.oss.console.app.model.po.UploadChannel;
 import cn.reghao.oss.console.util.AuthKeyContext;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
 /**
  * @author reghao
  * @date 2024-02-23 09:22:53
@@ -54,44 +50,6 @@ public class OssService {
         return new ServerInfo(ossUrl, channelId, maxSize, token);
     }
 
-    public List<ObjectChannel> getObjectChannels(String nodeAddr) {
-        StoreNode storeNode = storeNodeRepository.findByIpv4Addr(nodeAddr);
-        if (storeNode == null) {
-            return Collections.emptyList();
-        }
-
-        String domain = storeNode.getDomain();
-        return uploadChannelRepository.findByBindDomain(domain).stream()
-                .map(uploadChannel -> getObjectChannel(uploadChannel, domain))
-                .collect(Collectors.toList());
-    }
-
-    public ObjectChannel getObjectChannel(int createBy, String nodeAddr, int channelId) {
-        StoreNode storeNode = storeNodeRepository.findByIpv4Addr(nodeAddr);
-        if (storeNode == null) {
-            return null;
-        }
-
-        String domain = storeNode.getDomain();
-        UploadChannel uploadChannel = uploadChannelRepository.findByCreateByAndBindDomainAndChannelId(createBy, domain, channelId);
-        if (uploadChannel == null) {
-            return null;
-        }
-
-        return getObjectChannel(uploadChannel, domain);
-    }
-
-    private ObjectChannel getObjectChannel(UploadChannel uploadChannel, String domain) {
-        int channelId = uploadChannel.getChannelId();
-        String name = uploadChannel.getName();
-        String channelPrefix = uploadChannel.getPrefix();
-        long maxSize = uploadChannel.getMaxSize();
-        int fileType = uploadChannel.getFileType();
-        boolean processFile = uploadChannel.getProcessFile();
-        int scope = uploadChannel.getScope();
-        return new ObjectChannel(channelId, name, channelPrefix, maxSize, fileType, processFile, scope, domain);
-    }
-
     public ObjectInfo getObjectInfo(String objectId) {
         RemoteService<ObjectService> remoteService = new RemoteService<>();
         String host = "";

+ 83 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/service/OssStoreService.java

@@ -0,0 +1,83 @@
+package cn.reghao.oss.console.app.service;
+
+import cn.reghao.oss.console.app.db.repository.StoreNodeRepository;
+import cn.reghao.oss.console.app.db.repository.UploadChannelRepository;
+import cn.reghao.oss.console.app.model.po.StoreNode;
+import cn.reghao.oss.console.app.model.po.UploadChannel;
+import cn.reghao.oss.store.api.dto.ObjectChannel;
+import cn.reghao.oss.store.api.dto.StoreProperties;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2024-03-01 09:09:12
+ */
+@Service
+public class OssStoreService {
+    private final StoreNodeService storeNodeService;
+    private final StoreNodeRepository storeNodeRepository;
+    private final UploadChannelRepository uploadChannelRepository;
+
+    public OssStoreService(StoreNodeService storeNodeService, StoreNodeRepository storeNodeRepository,
+                           UploadChannelRepository uploadChannelRepository) {
+        this.storeNodeService = storeNodeService;
+        this.storeNodeRepository = storeNodeRepository;
+        this.uploadChannelRepository = uploadChannelRepository;
+
+    }
+
+    public void registerNode(StoreNode storeNode) {
+        storeNodeService.add(storeNode);
+    }
+
+    public List<ObjectChannel> getObjectChannels(String nodeAddr) {
+        StoreNode storeNode = storeNodeRepository.findByIpv4Addr(nodeAddr);
+        if (storeNode == null) {
+            return Collections.emptyList();
+        }
+
+        String domain = storeNode.getDomain();
+        return uploadChannelRepository.findByBindDomain(domain).stream()
+                .map(uploadChannel -> getObjectChannel(uploadChannel, domain))
+                .collect(Collectors.toList());
+    }
+
+    public ObjectChannel getObjectChannel(int createBy, String nodeAddr, int channelId) {
+        StoreNode storeNode = storeNodeRepository.findByIpv4Addr(nodeAddr);
+        if (storeNode == null) {
+            return null;
+        }
+
+        String domain = storeNode.getDomain();
+        UploadChannel uploadChannel = uploadChannelRepository.findByCreateByAndBindDomainAndChannelId(createBy, domain, channelId);
+        if (uploadChannel == null) {
+            return null;
+        }
+
+        return getObjectChannel(uploadChannel, domain);
+    }
+
+    private ObjectChannel getObjectChannel(UploadChannel uploadChannel, String domain) {
+        int channelId = uploadChannel.getChannelId();
+        String name = uploadChannel.getName();
+        String channelPrefix = uploadChannel.getPrefix();
+        long maxSize = uploadChannel.getMaxSize();
+        int fileType = uploadChannel.getFileType();
+        boolean processFile = uploadChannel.getProcessFile();
+        int scope = uploadChannel.getScope();
+        return new ObjectChannel(channelId, name, channelPrefix, maxSize, fileType, processFile, scope, domain);
+    }
+
+    public StoreProperties getStoreProperties(String nodeAddr) {
+        StoreNode storeNode = storeNodeRepository.findByIpv4Addr(nodeAddr);
+        String domain = storeNode.getDomain();
+        String referer = storeNode.getReferer();
+        String secretKey = storeNode.getSecretKey();
+        return new StoreProperties(domain, referer, secretKey);
+    }
+
+}

+ 1 - 9
oss-console/src/main/java/cn/reghao/oss/console/config/web/ConsoleAuthInterceptor.java

@@ -11,9 +11,6 @@ import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
 
 /**
  * oss-console 认证拦截
@@ -24,15 +21,10 @@ import java.util.Set;
 @Slf4j
 @Component
 public class ConsoleAuthInterceptor implements HandlerInterceptor {
-    private final Set<String> ignoreUrls = new HashSet<>();
     private final UserKeyService userKeyService;
 
     public ConsoleAuthInterceptor(UserKeyService userKeyService) {
         this.userKeyService = userKeyService;
-        this.ignoreUrls.addAll(List.of("/api/oss/key/auth",
-                "/api/oss/store/node/register",
-                "/api/oss/channel",
-                "/api/oss/channels"));
     }
 
     @Override
@@ -40,7 +32,7 @@ public class ConsoleAuthInterceptor implements HandlerInterceptor {
         String uri = request.getRequestURI();
         String method = request.getMethod();
         if (uri.startsWith("/api/oss/") && !method.equalsIgnoreCase("options")) {
-            if (ignoreUrls.contains(uri)) {
+            if (uri.startsWith("/api/oss/store") || uri.equals("/api/oss/key/auth")) {
                 return true;
             }
 

+ 2 - 0
oss-console/src/main/resources/templates/channel/index.html

@@ -54,6 +54,7 @@
                     <th class="sortable" data-field="appId">前缀</th>
                     <th class="sortable" data-field="repoBranch">最大文件</th>
                     <th class="sortable" data-field="repoBranch">文件类型</th>
+                    <th class="sortable" data-field="repoBranch">处理文件</th>
                     <th class="sortable" data-field="repoBranch">可见范围</th>
                     <th class="sortable" data-field="appName">绑定域名</th>
                     <th>操作</th>
@@ -66,6 +67,7 @@
                     <td th:text="${item.prefix}">前缀</td>
                     <td th:text="${item.maxSize}">最大文件</td>
                     <td th:text="${item.fileType}">文件类型</td>
+                    <td th:text="${item.processFile}">文件类型</td>
                     <td th:text="${item.scope}">可见范围</td>
                     <td th:text="${item.bindDomain}">绑定域名</td>
                     <td>

+ 0 - 62
oss-console/src/main/resources/templates/node/copy.html

@@ -1,62 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-
-<body>
-<div class="layui-form timo-compile">
-    <form th:action="@{'/api/app/config/app/copy/'}">
-        <input type="hidden" name="appId" th:value="${appId}"/>
-        <table class="layui-table timo-detail-table">
-            <tbody>
-            <tr>
-                <th>
-                    <label class="layui-form-label required">新应用 ID</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <label>
-                                <input class="layui-input" type="text" name="newAppId" placeholder="请输入应用 ID" required>
-                            </label>
-                        </div>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <th>
-                    <label class="layui-form-label required">新应用环境</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <select name="newEnv">
-                                <option th:each="item : ${environments}" th:value="${item.key}">[[${item.value}]]</option>
-                            </select>
-                        </div>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <th>
-                    <label class="layui-form-label required">新应用分支</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="newRepoBranch"  placeholder="请输入仓库分支" required>
-                        </div>
-                    </div>
-                </td>
-            </tr>
-            </tbody>
-        </table>
-        <div class="layui-form-item timo-finally">
-            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
-            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
-        </div>
-    </form>
-</div>
-
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>

+ 0 - 108
oss-console/src/main/resources/templates/node/deploy/add.html

@@ -1,108 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-
-<body>
-<div class="layui-form timo-compile">
-    <form th:action="@{/api/app/config/app/deploy}">
-        <table class="layui-table timo-detail-table">
-            <tbody>
-            <tr>
-                <th>
-                    <label class="layui-form-label required">选择机器</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <select name="machineId">
-                                <option th:each="item : ${machines}" th:value="${item.key}">[[${item.value}]]</option>
-                            </select>
-                        </div>
-                    </div>
-                </td>
-                <th>
-                    <label class="layui-form-label">应用 ID</label>
-                </th>
-                <td >
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appId" readonly th:value="${appId}">
-                        </div>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <th>
-                    <label class="layui-form-label">打包类型</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="packType" readonly th:value="${packType}">
-                        </div>
-                    </div>
-                </td>
-                <span th:if="${packType} ne 'docker' ">
-                    <th>
-                    <label class="layui-form-label required">启动目录</label>
-                    </th>
-                    <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="startHome" placeholder="可执行文件位置(可选)" required>
-                        </div>
-                    </div>
-                    </td>
-                </span>
-            </tr>
-            <tr>
-                <th>
-                    <label class="layui-form-label">启动脚本<i id="start_script_tips" class="fa fa-question-circle"></i></label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <textarea class="layui-textarea" name="startScript" placeholder="启动脚本(选填, docker 应用默认为空 JSON {})"></textarea>
-                        </div>
-                    </div>
-                </td>
-                <span th:if="${packType} ne 'docker' ">
-                <th>
-                    <label class="layui-form-label required">解包脚本</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <textarea class="layui-textarea" name="unpackScript" placeholder="解包脚本(可选)"></textarea>
-                        </div>
-                    </div>
-                </td>
-                </span>
-            </tr>
-            </tbody>
-        </table>
-        <div class="layui-form-item timo-finally">
-            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
-            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
-        </div>
-    </form>
-</div>
-
-<script th:replace="/common/template :: script"></script>
-<script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
-<script type="text/javascript">
-    $(function () {
-        $("#start_script_tips").hover(function () {
-            var tips = layer.tips(
-                '对于 docker 打包类型, 启动脚本是一个 JSON 字符串<br/>' +
-                '内容是 https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate 的 reqeust body<br/>',
-                '#start_script_tips',{
-                tips: [1, '#555555']
-            });
-            sleep(1000);
-            layer.close(tips);
-        })
-    })
-</script>
-</body>
-</html>

+ 0 - 39
oss-console/src/main/resources/templates/node/deploy/detail.html

@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-<body>
-    <div class="timo-detail-page">
-        <table class="layui-table timo-detail-table">
-            <tbody>
-            <tr>
-                <th>应用 ID</th>
-                <td th:text="${deployConfigVO.appId}"></td>
-                <th>机器地址</th>
-                <td th:text="${deployConfigVO.machineIpv4}"></td>
-            </tr>
-            <tr>
-                <th>打包类型</th>
-                <td th:text="${deployConfigVO.packType}"></td>
-                <span th:if="${deployConfigVO.packType} ne 'docker' ">
-                    <th>启动目录</th>
-                    <td th:text="${deployConfigVO.startHome}"></td>
-                </span>
-            </tr>
-            <tr>
-                <th>启动脚本</th>
-                <td>
-                    <textarea class="layui-textarea" readonly="readonly" th:text="${deployConfigVO.startScript}"></textarea>
-                </td>
-                <span th:if="${deployConfigVO.packType} ne 'docker' ">
-                <th>解包脚本</th>
-                <td>
-                    <textarea class="layui-textarea" readonly="readonly" th:text="${deployConfigVO.unpackScript}"></textarea>
-                </td>
-                </span>
-            </tr>
-            </tbody>
-        </table>
-    </div>
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>

+ 0 - 93
oss-console/src/main/resources/templates/node/deploy/edit.html

@@ -1,93 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-
-<body>
-<div class="layui-form timo-compile">
-    <form th:action="@{/api/app/config/app/deploy/update}">
-        <input type="hidden" name="machineId" th:value="${appDeployConfig.machineHost.machineId}"/>
-        <table class="layui-table timo-detail-table">
-            <tbody>
-            <tr>
-                <th>
-                    <label class="layui-form-label">机器地址</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="machineIpv4" readonly th:value="${appDeployConfig.machineHost.machineIpv4}">
-                        </div>
-                    </div>
-                </td>
-                <th>
-                    <label class="layui-form-label">应用 ID</label>
-                </th>
-                <td >
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appId" readonly th:value="${appDeployConfig.appConfig.appId}">
-                        </div>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <th>
-                    <label class="layui-form-label">打包类型</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="packType" readonly th:value="${appDeployConfig.appConfig.packerConfig.type}">
-                        </div>
-                    </div>
-                </td>
-                <span th:if="${appDeployConfig.appConfig.packerConfig.type} ne 'docker' ">
-                <th>
-                    <label class="layui-form-label required">启动目录</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="startHome" th:value="${appDeployConfig.startHome}">
-                        </div>
-                    </div>
-                </td>
-                </span>
-            </tr>
-            <tr>
-                <th>
-                    <label class="layui-form-label">启动脚本</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <textarea class="layui-textarea" name="startScript" th:text="${appDeployConfig.startScript}"></textarea>
-                        </div>
-                    </div>
-                </td>
-            </tr>
-            <span th:if="${appDeployConfig.appConfig.packerConfig.type} ne 'docker' ">
-                <tr>
-                <th>
-                    <label class="layui-form-label required">解包脚本</label>
-                </th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <textarea class="layui-textarea" name="unpackScript" th:text="${appDeployConfig.unpackScript}"></textarea>
-                        </div>
-                    </div>
-                </td>
-                </tr>
-            </span>
-            </tbody>
-        </table>
-        <div class="layui-form-item timo-finally">
-            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
-            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
-        </div>
-    </form>
-</div>
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>

+ 0 - 51
oss-console/src/main/resources/templates/node/deploy/index.html

@@ -1,51 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-
-<body class="timo-layout-page">
-<div class="layui-card">
-    <div class="layui-card-body">
-        <div class="layui-row timo-card-screen put-row">
-            <div class="pull-right screen-btn-group">
-                <div class="btn-group-right">
-                    <button class="layui-btn open-popup" data-title="添加部署配置" th:attr="data-url=@{'/app/config/app/deploy/add/'+${appId}}"
-                            data-size="1200,500">
-                        <i class="fa fa-plus"></i> 添加
-                    </button>
-                </div>
-            </div>
-        </div>
-        <div class="timo-table-wrap">
-            <table class="layui-table timo-table">
-                <thead>
-                <tr>
-                    <th class="sortable" data-field="appName">应用</th>
-                    <th class="sortable" data-field="machineIpv4">机器地址</th>
-                    <th class="sortable" data-field="packType">打包类型</th>
-                    <th class="sortable" data-field="startScript">启动脚本</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr th:each="item:${list}">
-                    <td th:text="${item.appName}">应用</td>
-                    <td th:text="${item.machineIpv4}">机器地址</td>
-                    <td th:text="${item.packType}">打包类型</td>
-                    <td th:text="${item.startScript}">启动脚本</td>
-                    <td>
-                        <a class="open-popup" data-title="部署配置详情" th:attr="data-url=@{'/app/config/app/deploy/detail/'+${appId}+'/'+${item.machineId}}"
-                           data-size="1000,500" href="#">详情</a>
-                        <a class="open-popup" data-title="修改部署配置" th:attr="data-url=@{'/app/config/app/deploy/edit/'+${appId}+'/'+${item.machineId}}"
-                           data-size="1000,500" href="#">编辑</a>
-                        <a class="ajax-delete" th:href="@{'/api/app/config/app/deploy/'+${item.appDeployConfigId}}">删除</a>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-        <div th:replace="/common/fragment :: page"></div>
-    </div>
-</div>
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>

+ 12 - 0
oss-console/src/main/resources/templates/node/edit.html

@@ -32,6 +32,18 @@
                     </div>
                 </td>
             </tr>
+            <tr>
+                <th>
+                    <label class="layui-form-label">referer</label>
+                </th>
+                <td>
+                    <div class="layui-form-item">
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="referer" th:value="${storeNode.referer}">
+                        </div>
+                    </div>
+                </td>
+            </tr>
             </tbody>
         </table>
         <div class="layui-form-item timo-finally">

+ 6 - 4
oss-console/src/main/resources/templates/node/index.html

@@ -52,7 +52,8 @@
                     <th class="sortable" data-field="appId">HTTP 端口</th>
                     <th class="sortable" data-field="repoBranch">RPC 端口</th>
                     <th class="sortable" data-field="appName">节点域名</th>
-                    <th class="sortable" data-field="appName">节点位置</th>
+                    <th class="sortable" data-field="appName">SecretKey</th>
+                    <th class="sortable" data-field="appName">启用</th>
                     <th>操作</th>
                 </tr>
                 </thead>
@@ -62,11 +63,12 @@
                     <td th:text="${item.httpPort}">应用 ID</td>
                     <td th:text="${item.rpcPort}">分支</td>
                     <td th:text="${item.domain}">应用名</td>
-                    <td th:text="${item.domain}">应用名</td>
+                    <td th:text="${item.secretKey}">应用名</td>
+                    <td th:text="${item.enabled}">应用名</td>
                     <td>
-                        <a class="open-popup" data-title="设置存储节点属性" th:attr="data-url=@{'/app/config/app/domain/'+${item.id}}"
+                        <a class="open-popup" data-title="设置存储节点属性" th:attr="data-url=@{'/store/node/config/'+${item.id}}"
                            data-size="640,480" href="#">设置</a>
-                        <a class="open-popup" data-title="应用详细信息" th:attr="data-url=@{'/app/config/app/detail/'+${item.id}}"
+                        <a class="open-popup" data-title="应用详细信息" th:attr="data-url=@{'/store/node/detail/'+${item.id}}"
                            data-size="640,480" href="#">详细</a>
                         <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.id}"
                            th:href="@{'/api/oss/store/node/' + ${item.id}}">删除</a>

+ 45 - 18
oss-sdk/src/main/java/cn/reghao/oss/sdk/OssConsoleClient.java

@@ -2,10 +2,7 @@ package cn.reghao.oss.sdk;
 
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.jutil.jdk.serializer.JsonConverter;
-import cn.reghao.oss.store.api.dto.DownloadUrl;
-import cn.reghao.oss.store.api.dto.ObjectChannel;
-import cn.reghao.oss.store.api.dto.ObjectInfo;
-import cn.reghao.oss.store.api.dto.ServerInfo;
+import cn.reghao.oss.store.api.dto.*;
 import cn.reghao.oss.store.api.dto.media.*;
 import com.google.gson.reflect.TypeToken;
 
@@ -66,8 +63,11 @@ public class OssConsoleClient {
         this.token = webResult.getData();
     }
 
+    // ****************************************************************************************************************
+    // oss-store 调用的接口(不需要认证)
+    // ****************************************************************************************************************
     public void registerNode(String jsonPayload) throws Exception {
-        String api = String.format("%s/api/oss/store/node/register", endpoint);
+        String api = String.format("%s/api/oss/store/register", endpoint);
         HttpClient httpClient = HttpClient.newBuilder().build();
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("content-type", "application/json")
@@ -89,10 +89,9 @@ public class OssConsoleClient {
         }
     }
 
-    public ServerInfo getServerInfo(int channelId) throws Exception {
-        String api = String.format("%s/api/oss/server/info?channelId=%s", endpoint, channelId);
+    public List<ObjectChannel> getObjectChannels(String nodeAddr) throws Exception {
+        String api = String.format("%s/api/oss/store/channels?nodeAddr=%s", endpoint, nodeAddr);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
-                .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)
                 .GET()
                 .build();
@@ -104,8 +103,8 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<ServerInfo>>(){}.getType();
-        WebResult<ServerInfo> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<List<ObjectChannel>>>(){}.getType();
+        WebResult<List<ObjectChannel>> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
@@ -114,8 +113,8 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public List<ObjectChannel> getObjectChannels(String nodeAddr) throws Exception {
-        String api = String.format("%s/api/oss/channels?nodeAddr=%s", endpoint, nodeAddr);
+    public ObjectChannel getObjectChannel(int createBy, String nodeAddr, int channelId) throws Exception {
+        String api = String.format("%s/api/oss/store/channel?createBy=%s&nodeAddr=%s&channelId=%s", endpoint, createBy, nodeAddr, channelId);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .version(HttpClient.Version.HTTP_1_1)
                 .GET()
@@ -128,8 +127,8 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<List<ObjectChannel>>>(){}.getType();
-        WebResult<List<ObjectChannel>> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<ObjectChannel>>(){}.getType();
+        WebResult<ObjectChannel> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
@@ -138,8 +137,8 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public ObjectChannel getObjectChannel(int createBy, String nodeAddr, int channelId) throws Exception {
-        String api = String.format("%s/api/oss/channel?createBy=%s&nodeAddr=%s&channelId=%s", endpoint, createBy, nodeAddr, channelId);
+    public StoreProperties getStoreProperties(String nodeAddr) throws Exception {
+        String api = String.format("%s/api/oss/store/properties?nodeAddr=%s", endpoint, nodeAddr);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .version(HttpClient.Version.HTTP_1_1)
                 .GET()
@@ -152,8 +151,36 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<ObjectChannel>>(){}.getType();
-        WebResult<ObjectChannel> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<StoreProperties>>(){}.getType();
+        WebResult<StoreProperties> webResult = JsonConverter.jsonToObject(body, type);
+        if (webResult.getCode() != 0) {
+            String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
+            throw new Exception(errMsg);
+        }
+
+        return webResult.getData();
+    }
+
+    // ****************************************************************************************************************
+    // Object 相关接口
+    // ****************************************************************************************************************
+    public ServerInfo getServerInfo(int channelId) throws Exception {
+        String api = String.format("%s/api/oss/server/info?channelId=%s", endpoint, channelId);
+        HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
+                .header("authorization", "Bearer " + token)
+                .version(HttpClient.Version.HTTP_1_1)
+                .GET()
+                .build();
+        HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
+        int statusCode = httpResponse.statusCode();
+        String body = httpResponse.body();
+        if (statusCode != 200) {
+            String errMsg = String.format("%s -> %s", statusCode, body);
+            throw new Exception(errMsg);
+        }
+
+        Type type = new TypeToken<WebResult<ServerInfo>>(){}.getType();
+        WebResult<ServerInfo> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);

+ 1 - 4
oss-store/bin/oss.yml

@@ -8,8 +8,5 @@ spring:
     password: Dev@123456
 oss:
   consoleEndpoint: http://ossconsole.reghao.cn
-  domain: oss.reghao.cn
   diskDirs:
-    - /opt/oss/disk/13f654c8-af87-4710-aac9-7aa086c99aec/
-  referer: reghao.cn
-  secretKey: oss-store
+    - /opt/oss/disk/13f654c8-af87-4710-aac9-7aa086c99aec/

+ 0 - 6
oss-store/src/main/java/cn/reghao/oss/store/config/OssProperties.java

@@ -17,11 +17,5 @@ import java.util.List;
 @ConfigurationProperties(prefix = "oss")
 public class OssProperties {
     private String consoleEndpoint;
-    @Deprecated
-    private String domain;
     private List<String> diskDirs;
-    @Deprecated
-    private String secretKey;
-    @Deprecated
-    private String referer;
 }

+ 1 - 1
oss-store/src/main/java/cn/reghao/oss/store/config/spring/AppLifecycle.java

@@ -100,7 +100,7 @@ public class AppLifecycle implements ApplicationRunner, DisposableBean {
 
         ossConsoleClient.registerNode(jsonPayload);
 
-        String api = String.format("%s/api/oss/store/node/register", springProperties.getConsoleEndpoint());
+        String api = String.format("%s/api/oss/store/register", springProperties.getConsoleEndpoint());
         HttpClient httpClient = HttpClient.newBuilder().build();
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("content-type", "application/json")

+ 7 - 7
oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectGetController.java

@@ -4,10 +4,10 @@ import cn.reghao.oss.store.api.constant.ChannelAction;
 import cn.reghao.oss.store.api.constant.ObjectScope;
 import cn.reghao.oss.store.api.dto.ObjectChannel;
 import cn.reghao.oss.store.api.dto.ObjectMeta;
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.db.repository.ObjectRepository;
 import cn.reghao.oss.store.service.GetObjectService;
 import cn.reghao.oss.store.service.ObjectChannelService;
+import cn.reghao.oss.store.service.StoreService;
 import cn.reghao.oss.store.util.JwtUtil;
 import cn.reghao.oss.store.util.ObjectUtil;
 import cn.reghao.oss.store.util.SignatureUtil;
@@ -28,15 +28,15 @@ import java.util.concurrent.TimeUnit;
 public class ObjectGetController {
     private final GetObjectService getObjectService;
     private final Cache<String, String> cache;
-    private final OssProperties ossProperties;
+    private final StoreService storeService;
     private final ObjectChannelService objectChannelService;
     private final ObjectRepository objectRepository;
 
-    public ObjectGetController(GetObjectService getObjectService, OssProperties ossProperties,
+    public ObjectGetController(GetObjectService getObjectService, StoreService storeService,
                                ObjectChannelService objectChannelService, ObjectRepository objectRepository) {
         this.getObjectService = getObjectService;
         this.cache = Caffeine.newBuilder().maximumSize(10_000).expireAfterAccess(1, TimeUnit.HOURS).build();
-        this.ossProperties = ossProperties;
+        this.storeService = storeService;
         this.objectChannelService = objectChannelService;
         this.objectRepository = objectRepository;
     }
@@ -71,10 +71,10 @@ public class ObjectGetController {
         }
 
         String queryString = String.format("token=%s&t=%s&nonce=%s", token, timestamp, nonce);
-        String domain = ossProperties.getDomain();
+        String domain = storeService.getDomain();
         String url = String.format("//%s/%s", domain, objectName);
         String requestString = String.format("%s%s?%s", "GET", url, queryString);
-        boolean valid = SignatureUtil.valid(requestString, ossProperties.getSecretKey(), sign);
+        boolean valid = SignatureUtil.valid(requestString, storeService.getSecretKey(), sign);
         if (!valid) {
             String payload = "sign invalid";
             getObjectService.writeResponse(HttpServletResponse.SC_FORBIDDEN, payload);
@@ -96,7 +96,7 @@ public class ObjectGetController {
             return;
         }*/
 
-        OssPayload ossPayload = JwtUtil.getOssPayload(token, ossProperties.getSecretKey());
+        OssPayload ossPayload = JwtUtil.getOssPayload(token, storeService.getSecretKey());
         int channelId = ossPayload.getChannelId();
         ObjectChannel objectChannel = objectChannelService.getObjectChannel(channelId);
         if (objectChannel == null) {

+ 5 - 6
oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectUploadController.java

@@ -1,7 +1,6 @@
 package cn.reghao.oss.store.controller;
 
 import cn.reghao.oss.store.api.dto.ObjectChannel;
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.model.vo.ObjectProp;
 import cn.reghao.oss.store.model.vo.ObjectResult;
 import cn.reghao.oss.store.service.*;
@@ -35,19 +34,19 @@ public class ObjectUploadController {
     private final ObjectNameService objectNameService;
     private final PutObjectService putObjectService;
     private final FileProcessor fileProcessor;
-    private final OssProperties ossProperties;
     private final ObjectChannelService objectChannelService;
+    private String secretKey;
 
     public ObjectUploadController(ChannelValidateService channelValidateService, FileStoreService fileStoreService,
                                   ObjectNameService objectNameService, PutObjectService putObjectService,
-                                  FileProcessor fileProcessor, OssProperties ossProperties,
-                                  ObjectChannelService objectChannelService) {
+                                  FileProcessor fileProcessor, ObjectChannelService objectChannelService,
+                                  StoreService storeService) {
         this.channelValidateService = channelValidateService;
         this.fileStoreService = fileStoreService;
         this.objectNameService = objectNameService;
         this.putObjectService = putObjectService;
         this.fileProcessor = fileProcessor;
-        this.ossProperties = ossProperties;
+        this.secretKey = storeService.getSecretKey();
         this.objectChannelService = objectChannelService;
     }
 
@@ -66,7 +65,7 @@ public class ObjectUploadController {
                     .body(WebResult.failWithMsg("no token in request"));
         }
 
-        OssPayload ossPayload = JwtUtil.getOssPayload(token, ossProperties.getSecretKey());
+        OssPayload ossPayload = JwtUtil.getOssPayload(token, secretKey);
         String action = ossPayload.getAction();
         if (!"upload".equals(action)) {
             return ResponseEntity.status(HttpStatus.FORBIDDEN)

+ 4 - 4
oss-store/src/main/java/cn/reghao/oss/store/inerceptor/AccessLogInterceptor.java

@@ -1,7 +1,7 @@
 package cn.reghao.oss.store.inerceptor;
 
 import cn.reghao.jutil.web.ServletUtil;
-import cn.reghao.oss.store.config.OssProperties;
+import cn.reghao.oss.store.service.StoreService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.lang.Nullable;
 import org.springframework.stereotype.Component;
@@ -22,8 +22,8 @@ import javax.servlet.http.HttpServletResponse;
 public class AccessLogInterceptor implements HandlerInterceptor {
     private final String referFrom;
 
-    public AccessLogInterceptor(OssProperties ossProperties) {
-        this.referFrom = ossProperties.getReferer();
+    public AccessLogInterceptor(StoreService storeService) {
+        this.referFrom = storeService.getReferer();
     }
 
     @Override
@@ -45,7 +45,7 @@ public class AccessLogInterceptor implements HandlerInterceptor {
         String objectName = uri.replaceFirst("/", "");
         if (objectName.startsWith("img/")) {
             return true;
-        } else if (referer == null || !referer.contains(referFrom)) {
+        } else if (referer == null || (referFrom != null && !referer.contains(referFrom))) {
             log.error("request object {} from {} has been blocked", uri, referer);
             response.setStatus(403);
             return false;

+ 5 - 5
oss-store/src/main/java/cn/reghao/oss/store/inerceptor/TokenFilter.java

@@ -1,6 +1,6 @@
 package cn.reghao.oss.store.inerceptor;
 
-import cn.reghao.oss.store.config.OssProperties;
+import cn.reghao.oss.store.service.StoreService;
 import cn.reghao.oss.store.util.JwtUtil;
 import cn.reghao.oss.store.util.UserContext;
 import cn.reghao.jutil.web.ServletUtil;
@@ -16,10 +16,10 @@ import java.io.IOException;
  */
 @Component
 public class TokenFilter implements Filter {
-    private final OssProperties ossProperties;
+    private final String secretKey;
 
-    public TokenFilter(OssProperties ossProperties) {
-        this.ossProperties = ossProperties;
+    public TokenFilter(StoreService storeService) {
+        this.secretKey = storeService.getSecretKey();
     }
 
     @Override
@@ -32,7 +32,7 @@ public class TokenFilter implements Filter {
         int userId = -1;
         String token = ServletUtil.getBearerToken(request);
         if (token != null) {
-            OssPayload ossPayload = JwtUtil.getOssPayload(token, ossProperties.getSecretKey());
+            OssPayload ossPayload = JwtUtil.getOssPayload(token, secretKey);
             userId = ossPayload.getUserId();
         }
 

+ 5 - 5
oss-store/src/main/java/cn/reghao/oss/store/rpc/OssServerServiceImpl.java

@@ -2,8 +2,8 @@ package cn.reghao.oss.store.rpc;
 
 import cn.reghao.oss.store.api.constant.ObjectScope;
 import cn.reghao.oss.store.api.dto.ObjectChannel;
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.service.ObjectNameService;
+import cn.reghao.oss.store.service.StoreService;
 import cn.reghao.oss.store.util.JwtUtil;
 import cn.reghao.oss.store.api.constant.ChannelAction;
 import cn.reghao.oss.store.api.dto.OssPayload;
@@ -19,11 +19,11 @@ import org.springframework.stereotype.Service;
 @DubboService
 @Service
 public class OssServerServiceImpl implements OssServerService {
-    private final OssProperties ossProperties;
+    private final String secretKey;
     private final ObjectNameService objectNameService;
 
-    public OssServerServiceImpl(OssProperties ossProperties, ObjectNameService objectNameService) {
-        this.ossProperties = ossProperties;
+    public OssServerServiceImpl(StoreService storeService, ObjectNameService objectNameService) {
+        this.secretKey = storeService.getSecretKey();
         this.objectNameService = objectNameService;
     }
 
@@ -32,7 +32,7 @@ public class OssServerServiceImpl implements OssServerService {
         String action = ChannelAction.upload.getName();
         long expireAt = System.currentTimeMillis() + 3600*1000;
         OssPayload ossPayload = new OssPayload(action, channelId, userId);
-        return JwtUtil.createToken(ossPayload, expireAt, ossProperties.getSecretKey());
+        return JwtUtil.createToken(ossPayload, expireAt, secretKey);
     }
 
     @Override

+ 3 - 3
oss-store/src/main/java/cn/reghao/oss/store/rpc/SignService.java

@@ -1,7 +1,7 @@
 package cn.reghao.oss.store.rpc;
 
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.service.ObjectChannelService;
+import cn.reghao.oss.store.service.StoreService;
 import cn.reghao.oss.store.util.JwtUtil;
 import cn.reghao.oss.store.util.SignatureUtil;
 import cn.reghao.oss.store.api.constant.ChannelAction;
@@ -22,8 +22,8 @@ public class SignService {
     private final String secretKey;
     private final ObjectChannelService objectChannelService;
 
-    public SignService(OssProperties ossProperties, ObjectChannelService objectChannelService) {
-        this.secretKey = ossProperties.getSecretKey();
+    public SignService(StoreService storeService, ObjectChannelService objectChannelService) {
+        this.secretKey = storeService.getSecretKey();
         this.objectChannelService = objectChannelService;
     }
 

+ 3 - 3
oss-store/src/main/java/cn/reghao/oss/store/rpc/disk/FileServiceImpl.java

@@ -4,10 +4,10 @@ import cn.reghao.oss.store.api.constant.ObjectScope;
 import cn.reghao.oss.store.api.dto.DirProp;
 import cn.reghao.oss.store.api.dto.FileProp;
 import cn.reghao.oss.store.api.iface.disk.FileService;
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.db.mapper.FileMetaMapper;
 import cn.reghao.oss.store.model.po.FileMeta;
 import cn.reghao.oss.store.service.PutObjectService;
+import cn.reghao.oss.store.service.StoreService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.stereotype.Service;
@@ -28,10 +28,10 @@ public class FileServiceImpl implements FileService {
     private final FileMetaMapper fileMetaMapper;
     private final String domain;
 
-    public FileServiceImpl(PutObjectService putObjectService, FileMetaMapper fileMetaMapper, OssProperties ossProperties) {
+    public FileServiceImpl(PutObjectService putObjectService, FileMetaMapper fileMetaMapper, StoreService storeService) {
         this.fileMetaMapper = fileMetaMapper;
         this.putObjectService = putObjectService;
-        this.domain = ossProperties.getDomain();
+        this.domain = storeService.getDomain();
     }
 
     @Override

+ 2 - 4
oss-store/src/main/java/cn/reghao/oss/store/service/GetObjectService.java

@@ -1,8 +1,6 @@
 package cn.reghao.oss.store.service;
 
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.db.mapper.FileMetaMapper;
-import cn.reghao.oss.store.db.repository.ObjectRepository;
 import cn.reghao.oss.store.model.dto.ContentRange;
 import cn.reghao.oss.store.model.po.FileMeta;
 import cn.reghao.oss.store.api.dto.ObjectMeta;
@@ -28,9 +26,9 @@ public class GetObjectService {
     private final int bufSize = 1024*1024;
     private final String domain;
 
-    public GetObjectService(FileMetaMapper fileMetaMapper, OssProperties ossProperties) {
+    public GetObjectService(FileMetaMapper fileMetaMapper, StoreService storeService) {
         this.fileMetaMapper = fileMetaMapper;
-        this.domain = ossProperties.getDomain();
+        this.domain = storeService.getDomain();
     }
     
     public void headObject(String objectName) throws IOException {

+ 2 - 3
oss-store/src/main/java/cn/reghao/oss/store/service/ObjectMultipartUploadService.java

@@ -1,7 +1,6 @@
 package cn.reghao.oss.store.service;
 
 import cn.reghao.oss.store.api.dto.ObjectChannel;
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.db.mapper.FileMetaMapper;
 import cn.reghao.oss.store.model.dto.PathUrl;
 import cn.reghao.oss.store.model.vo.ObjectProp;
@@ -38,12 +37,12 @@ public class ObjectMultipartUploadService {
 
     public ObjectMultipartUploadService(FileMetaMapper fileMetaMapper, FileStoreService fileStoreService,
                                         ObjectNameService objectNameService, PutObjectService putObjectService,
-                                        OssProperties ossProperties) {
+                                        StoreService storeService) {
         this.fileMetaMapper = fileMetaMapper;
         this.fileStoreService = fileStoreService;
         this.objectNameService = objectNameService;
         this.putObjectService = putObjectService;
-        this.domain = ossProperties.getDomain();
+        this.domain = storeService.getDomain();
     }
 
     public synchronized UploadPrepareRet prepareUpload(UploadPrepare uploadPrepare) {

+ 2 - 3
oss-store/src/main/java/cn/reghao/oss/store/service/ObjectNameService.java

@@ -1,7 +1,6 @@
 package cn.reghao.oss.store.service;
 
 import cn.reghao.oss.store.api.dto.ObjectChannel;
-import cn.reghao.oss.store.config.OssProperties;
 import cn.reghao.oss.store.db.repository.ObjectRepository;
 import cn.reghao.oss.store.model.po.FileMeta;
 import cn.reghao.oss.store.model.vo.ObjectProp;
@@ -21,9 +20,9 @@ public class ObjectNameService {
     private final ObjectRepository objectRepository;
     private final String domain;
 
-    public ObjectNameService(ObjectRepository objectRepository, OssProperties ossProperties) {
+    public ObjectNameService(ObjectRepository objectRepository, StoreService storeService) {
         this.objectRepository = objectRepository;
-        this.domain = ossProperties.getDomain();
+        this.domain = storeService.getDomain();
     }
 
     public String getObjectUrl(String objectName) {

+ 57 - 0
oss-store/src/main/java/cn/reghao/oss/store/service/StoreService.java

@@ -0,0 +1,57 @@
+package cn.reghao.oss.store.service;
+
+import cn.reghao.jutil.jdk.machine.id.MachineId;
+import cn.reghao.oss.sdk.OssConsoleClient;
+import cn.reghao.oss.store.api.dto.StoreProperties;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author reghao
+ * @date 2024-03-01 08:53:28
+ */
+@Service
+public class StoreService {
+    private final String nodeAddr;
+    private final OssConsoleClient ossConsoleClient;
+    private StoreProperties storeProperties;
+
+    public StoreService(MachineId machineId, OssConsoleClient ossConsoleClient) {
+        this.nodeAddr = machineId.ipv4();
+        this.ossConsoleClient = ossConsoleClient;
+    }
+
+    @PostConstruct
+    public void getStoreProperties() {
+        try {
+            this.storeProperties = ossConsoleClient.getStoreProperties(nodeAddr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getDomain() {
+        if (storeProperties == null) {
+            getStoreProperties();
+        }
+
+        return storeProperties.getDomain();
+    }
+
+    public String getReferer() {
+        if (storeProperties == null) {
+            getStoreProperties();
+        }
+
+        return storeProperties != null ? storeProperties.getReferer() : null;
+    }
+
+    public String getSecretKey() {
+        if (storeProperties == null) {
+            getStoreProperties();
+        }
+
+        return storeProperties.getSecretKey();
+    }
+}

+ 16 - 0
store-api/src/main/java/cn/reghao/oss/store/api/dto/StoreProperties.java

@@ -0,0 +1,16 @@
+package cn.reghao.oss.store.api.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author reghao
+ * @date 2024-03-01 09:22:17
+ */
+@AllArgsConstructor
+@Getter
+public class StoreProperties {
+    private String domain;
+    private String referer;
+    private String secretKey;
+}