Compare commits
8 Commits
rel-23.07.
...
dev-3.10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58a61ff40c | ||
|
|
7d7f350e4d | ||
|
|
fc3a2b4591 | ||
|
|
0d9e0d5be4 | ||
|
|
4bd4109faa | ||
|
|
77439ea58a | ||
|
|
ed091f73ac | ||
|
|
6edf086b06 |
@@ -1,5 +1,5 @@
|
||||
# docker镜像
|
||||
image: git.mesalab.cn:7443/nezha/nz-build-env:1.3
|
||||
image: git.mesalab.cn:7443/nezha/nz-build-env:1.5
|
||||
# 定义全局变量
|
||||
variables:
|
||||
MINIO_HOST: 'http://192.168.40.48:2020/'
|
||||
@@ -64,9 +64,11 @@ dev_build:
|
||||
- chmod +x xjar
|
||||
- "git log -100 --pretty=format:'%ad : %s' >> git-log.html"
|
||||
- tar -zcvf $FILE_NAME xjar nz-talon.xjar git-log.html
|
||||
- md5sum $FILE_NAME > $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz.md5sum.txt
|
||||
- mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
||||
- mc cp $FILE_NAME nz/ci-cd/nz-talon/$FILE_NAME
|
||||
- mc cp $FILE_NAME nz/ci-cd/nz-talon/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz
|
||||
- mc cp $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz.md5sum.txt nz/ci-cd/nz-talon/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz.md5sum.txt
|
||||
- cd ../
|
||||
artifacts:
|
||||
name: "$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
||||
|
||||
14
pom.xml
14
pom.xml
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.4.4</version>
|
||||
<version>3.1.3</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>net.geedge</groupId>
|
||||
@@ -15,7 +15,7 @@
|
||||
<name>nz-talon</name>
|
||||
<description>nezha promtail config sync talon</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<java.version>21</java.version>
|
||||
<log4j2.version>2.17.0</log4j2.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
@@ -27,6 +27,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -66,6 +67,15 @@
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<release>${java.version}</release>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
package net.geedge.confagent.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import net.geedge.confagent.annotation.UnCheckToken;
|
||||
import net.geedge.confagent.entity.AuthEntity;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value={"/auth"})
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.geedge.confagent.controller;
|
||||
|
||||
|
||||
import net.geedge.confagent.util.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.geedge.confagent.util.OSHIUtils;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.geedge.confagent.controller;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
@@ -11,8 +12,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -2,16 +2,18 @@ package net.geedge.confagent.controller;
|
||||
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.net.url.UrlPath;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpConnection;
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.geedge.confagent.annotation.UnCheckToken;
|
||||
import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -24,11 +26,6 @@ import java.net.HttpURLConnection;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/promtail")
|
||||
public class PromtailController extends BaseController{
|
||||
@@ -203,7 +200,7 @@ public class PromtailController extends BaseController{
|
||||
}
|
||||
|
||||
public void requestProm(String host, int port, String path, HttpServletRequest request, HttpServletResponse response) {
|
||||
String queryString = ReflectUtil.invoke(request, "getQueryString");
|
||||
String queryString = request.getQueryString();
|
||||
queryString = StrUtil.isNotBlank(queryString)?queryString:"";
|
||||
String url = UrlBuilder.create().setScheme("http").setHost(host).setPort(port).setPath(UrlPath.of(path, Charset.forName("UTF-8"))).toURL().toString() + "?" + queryString;
|
||||
|
||||
@@ -224,7 +221,7 @@ public class PromtailController extends BaseController{
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String hn = headerNames.nextElement();
|
||||
if(!"authorization".equalsIgnoreCase(hn)) {
|
||||
ReflectUtil.invoke(conn,"addRequestProperty",hn,request.getHeader(hn));
|
||||
conn.addRequestProperty(hn, request.getHeader(hn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,10 +242,12 @@ public class PromtailController extends BaseController{
|
||||
String key = en.getKey();
|
||||
if (Tool.StrUtil.isEmpty(key) || "Transfer-Encoding".equals(key)) continue;
|
||||
List<String> value = en.getValue();
|
||||
ReflectUtil.invoke(response,"addHeader",key,Tool.StrUtil.join("; ",value));
|
||||
response.addHeader(key, Tool.StrUtil.join("; ", value));
|
||||
}
|
||||
response.setStatus(responseCode);
|
||||
if (responseCode > 400) {
|
||||
response.sendError(responseCode, responseMessage);
|
||||
}
|
||||
ReflectUtil.invoke(response, "setStatus", responseCode, responseMessage);
|
||||
|
||||
Tool.IoUtil.copy(connInputStream, resOutputStream);
|
||||
resOutputStream.flush();//flush 输出流
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
package net.geedge.confagent.interceptor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.geedge.confagent.annotation.UnCheckToken;
|
||||
import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@Component
|
||||
public class TokenInterceptor implements HandlerInterceptor {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package net.geedge.confagent.util;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -8,15 +15,6 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.log.Log;
|
||||
|
||||
@Configuration
|
||||
@Order(value = 1)
|
||||
public class ConfagentUtil {
|
||||
|
||||
@@ -3,7 +3,10 @@ package net.geedge.confagent.util;
|
||||
import cn.hutool.log.Log;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.*;
|
||||
import oshi.software.os.*;
|
||||
import oshi.software.os.InternetProtocolStats;
|
||||
import oshi.software.os.NetworkParams;
|
||||
import oshi.software.os.OSProcess;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
@@ -97,7 +100,7 @@ public class OSHIUtils {
|
||||
}
|
||||
|
||||
List<HashMap<Object, Object>> network = Tool.ListUtil.list(false);
|
||||
List<NetworkIF> networkIFs = hal.getNetworkIFs();
|
||||
List<NetworkIF> networkIFs = hal.getNetworkIFs(true);
|
||||
for (NetworkIF networkIF : networkIFs) {
|
||||
HashMap<Object, Object> networkData = Tool.MapUtil.newHashMap();
|
||||
networkData.put("index", networkIF.getIndex());
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package net.geedge.confagent.util;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import net.geedge.confagent.ConfagentApplication;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Robot;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.ref.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLDecoder;
|
||||
@@ -26,13 +26,6 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Spliterator;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
public class Tool {
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,10 +80,8 @@ restoreComponentConfig(){
|
||||
|
||||
for i in $(ls $2);do
|
||||
if [ 1 -eq `compareMD5 $1/$i $2/$i` ];then
|
||||
if [ -f $1/${i} ];then
|
||||
echo 'return config file '$1/${i}
|
||||
cp -f $2/$i $1/$i
|
||||
fi
|
||||
echo 'return config file '$1/${i}
|
||||
cp -f $2/$i $1/$i
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -112,7 +110,8 @@ Description=nz-talon
|
||||
After=network.target
|
||||
[Service]
|
||||
WorkingDirectory=/opt/nezha/nz-talon
|
||||
ExecStart=/opt/nezha/nz-talon/xjar ${JAVA_EXE} -Dnz-agent.dir=/opt/nezha/nz-talon -jar /opt/nezha/nz-talon/nz-talon.xjar
|
||||
EnvironmentFile=-/opt/nezha/nz-talon/config/config.conf
|
||||
ExecStart=/opt/nezha/nz-talon/xjar ${JAVA_EXE} --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED -Dnz-agent.dir=/opt/nezha/nz-talon -jar /opt/nezha/nz-talon/nz-talon.xjar
|
||||
RestartSec=5s
|
||||
Restart=always
|
||||
[Install]
|
||||
|
||||
@@ -12,7 +12,7 @@ fi
|
||||
RPM_FULL_NAME=${PACKAGE_NAME}-${PACKAGE_VERSION}-${ITERATION}.x86_64.rpm
|
||||
|
||||
# 依赖jdk 文件名
|
||||
JDK_FILENAME=jdk-8u202-linux-x64.tar.gz
|
||||
JDK_FILENAME=openjdk-21_linux-x64_bin.tar.gz
|
||||
|
||||
# 初始化 minio
|
||||
mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
||||
@@ -51,8 +51,8 @@ mc cp nz/depends/jdk/$JDK_FILENAME ./
|
||||
tar -xzf ./$JDK_FILENAME --strip-components 1 -C $RPM_JDK_PATH
|
||||
|
||||
# 下载 promtail
|
||||
mc cp nz/depends/loki/promtail-linux-amd64.zip ./
|
||||
unzip -o promtail-linux-amd64.zip -d $RPM_PROMTAIL_PATH
|
||||
mc cp nz/depends/loki/promtail-2.9.0.linux-amd64.zip ./
|
||||
unzip -o promtail-2.9.0.linux-amd64.zip -d $RPM_PROMTAIL_PATH
|
||||
mv $RPM_PROMTAIL_PATH/promtail-linux-amd64 $RPM_PROMTAIL_PATH/promtail
|
||||
cp -f ./tools/config.conf $RPM_PROMTAIL_PATH
|
||||
cp -f ./tools/promtail.yaml $RPM_PROMTAIL_PATH
|
||||
|
||||
Reference in New Issue
Block a user