Browse Source

Move frp.cpp separately to improve build speed

xcbosa-itx 2 years ago
parent
commit
3fab844b8e
3 changed files with 32 additions and 6 deletions
  1. 5 5
      frp.cpp
  2. 26 0
      frp.h
  3. 1 1
      main.cpp

+ 5 - 5
frp.hpp → frp.cpp

@@ -17,7 +17,7 @@ using namespace xc::utils;
 
 namespace frp {
 
-    static set<int> profileUsingPorts(string profile) {
+    set<int> profileUsingPorts(string profile) {
         set<int> usingPorts;
         INIFile ini(conf::getFrpcDir() + "/" + profile);
         string value = ini.getMust("common")->get("webui_allowServerPorts");
@@ -35,7 +35,7 @@ namespace frp {
         return usingPorts;
     }
 
-    static set<int> serverUsingPorts(string serverIp) {
+    set<int> serverUsingPorts(string serverIp) {
         set<int> usingPorts;
         for (string file : fs::contentsOfDirectory(conf::getFrpcDir())) {
             INIFile ini(conf::getFrpcDir() + "/" + file);
@@ -49,7 +49,7 @@ namespace frp {
         return usingPorts;
     }
 
-    static void addProfile(string name, string ip, string port, string token) {
+    void addProfile(string name, string ip, string port, string token) {
         INI ini;
         auto frpCommon = ini.getMust("common");
         frpCommon->set("server_addr", ip);
@@ -160,13 +160,13 @@ namespace frp {
     set<string> reloadConfigForFilePathRequests;
     mutex reloadConfigForFilePathRequestsLocker;
 
-    static void reloadProfileFilePath(string filePath) {
+    void reloadProfileFilePath(string filePath) {
         reloadConfigForFilePathRequestsLocker.lock();
         reloadConfigForFilePathRequests.insert(filePath);
         reloadConfigForFilePathRequestsLocker.unlock();
     }
 
-    static void frpDaemon() {
+    void frpDaemon() {
         char readBuff[1024];
         vector<FrpProcessWrapper *> frpProcesses;
         while (true) {

+ 26 - 0
frp.h

@@ -0,0 +1,26 @@
+//
+// Created by xcbosa on 2023/1/31.
+//
+
+#pragma once
+
+#include <string>
+#include "utils/utils.h"
+#include "webuiconf.h"
+#include "fs.hpp"
+#include <signal.h>
+#include <strstream>
+
+using namespace std;
+using namespace xc;
+using namespace xc::utils;
+
+namespace frp {
+
+    set<int> profileUsingPorts(string profile);
+    set<int> serverUsingPorts(string serverIp);
+    void addProfile(string name, string ip, string port, string token);
+    void reloadProfileFilePath(string filePath);
+    void frpDaemon();
+
+}

+ 1 - 1
main.cpp

@@ -6,7 +6,7 @@
 #include "processor/processor.h"
 #include "fs.hpp"
 #include "thirdparty/sha256.hpp"
-#include "frp.hpp"
+#include "frp.h"
 
 using namespace xc;
 using namespace xc::httpserver;