Commit 9a8477e9 authored by Administrator's avatar Administrator

Merge branch 'staging' into 'master'

Staging

See merge request !52
parents 96346f82 8e6a858f
...@@ -8,6 +8,7 @@ import com.edgec.browserbackend.account.domain.*; ...@@ -8,6 +8,7 @@ import com.edgec.browserbackend.account.domain.*;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode; import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.common.auth.Securitys; import com.edgec.browserbackend.common.auth.Securitys;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
...@@ -31,6 +32,8 @@ import java.util.Map; ...@@ -31,6 +32,8 @@ import java.util.Map;
@RequestMapping("/vpsadmin") @RequestMapping("/vpsadmin")
public class AdministratorController { public class AdministratorController {
static final String mykey = "Xi6JZQ1SbUTxjO62u1MX01hBeB7A!qQXR6jVfer@s8@9JZxNqB@NTs$vpwH9aVXe";
@Autowired @Autowired
private AdministratorService administratorService; private AdministratorService administratorService;
@Autowired @Autowired
...@@ -301,7 +304,7 @@ public class AdministratorController { ...@@ -301,7 +304,7 @@ public class AdministratorController {
e.printStackTrace(); e.printStackTrace();
throw new ClientRequestException(BrowserErrorCode.UNKNOWN); throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}finally { }finally {
tempFile.deleteOnExit(); tempFile.delete();
} }
resultDto.setStatus(0); resultDto.setStatus(0);
}catch (ClientRequestException e) { }catch (ClientRequestException e) {
...@@ -426,6 +429,33 @@ public class AdministratorController { ...@@ -426,6 +429,33 @@ public class AdministratorController {
return resultDto; return resultDto;
} }
//获取3proxy.cfg
@RequestMapping(path = "/0xadministrator/getconfig", method = RequestMethod.GET)
public void getProxyConfig(@RequestParam("key") String key, HttpServletResponse response) {
File file = null;
if (StringUtils.isNotBlank(key) && key.equals(mykey))
file = administratorService.getProxyConfig();
if (file != null) {
try(OutputStream os = response.getOutputStream();
FileInputStream fis = new FileInputStream(file)){
response.setHeader("content-type", "application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("3proxy.cfg", "UTF-8"));
int len =0;
byte[] bt = new byte[5*1024];
while((len = fis.read(bt)) != -1) {
os.write(bt,0,len);
}
}catch(Exception e) {
e.printStackTrace();
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}finally {
file.delete();
}
}
}
} }
......
...@@ -41,7 +41,7 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc ...@@ -41,7 +41,7 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
List<Account> findByNameIn(List<String> names); List<Account> findByNameIn(List<String> names);
List<Account> findByPromotionCode(String code); List<Account> findByPromotionCodeAndParentIsNull(String code);
int countByPromotionCodeAndParentIsNull(String promotionCode); int countByPromotionCodeAndParentIsNull(String promotionCode);
} }
package com.edgec.browserbackend.account.repository; package com.edgec.browserbackend.account.repository;
import com.edgec.browserbackend.account.domain.CompanyAuthorize; import com.edgec.browserbackend.account.domain.CompanyAuthorize;
import com.edgec.browserbackend.account.dto.CompanyAuthorizeDto;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
public interface CompanyAuthorizeRepository extends MongoRepository<CompanyAuthorize, String>, CompanyAuthorizeRepositoryCustom { public interface CompanyAuthorizeRepository extends MongoRepository<CompanyAuthorize, String>, FileRepository {
CompanyAuthorize findByUsername(String username); CompanyAuthorize findByUsername(String username);
} }
...@@ -5,8 +5,10 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -5,8 +5,10 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
public interface CompanyAuthorizeRepositoryCustom { public interface FileRepository {
String saveFile(MultipartFile file, String filename); String saveFile(MultipartFile file, String filename);
String saveFile(File file, String filename);
void deleteFile(String fileId); void deleteFile(String fileId);
File getFile(String fileId); File getFile(String fileId, String suffix);
String updateFile(File file, String filename);
} }
...@@ -2,18 +2,13 @@ package com.edgec.browserbackend.account.repository; ...@@ -2,18 +2,13 @@ package com.edgec.browserbackend.account.repository;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode; import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import com.mongodb.DB;
import com.mongodb.client.gridfs.GridFSBucket; import com.mongodb.client.gridfs.GridFSBucket;
import com.mongodb.client.gridfs.GridFSDownloadStream; import com.mongodb.client.gridfs.GridFSDownloadStream;
import com.mongodb.client.gridfs.model.GridFSFile; import com.mongodb.client.gridfs.model.GridFSFile;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSDBFile;
import com.mongodb.gridfs.GridFSInputFile;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
...@@ -22,14 +17,11 @@ import org.springframework.data.mongodb.gridfs.GridFsResource; ...@@ -22,14 +17,11 @@ import org.springframework.data.mongodb.gridfs.GridFsResource;
import org.springframework.data.mongodb.gridfs.GridFsTemplate; import org.springframework.data.mongodb.gridfs.GridFsTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayOutputStream; import java.io.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRepositoryCustom { public class FileRepositoryImpl implements FileRepository {
private final Logger logger = LoggerFactory.getLogger(CompanyAuthorizeRepositoryCustomImpl.class); private final Logger logger = LoggerFactory.getLogger(FileRepositoryImpl.class);
@Autowired @Autowired
private GridFsTemplate gridFsTemplate; private GridFsTemplate gridFsTemplate;
...@@ -56,6 +48,18 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep ...@@ -56,6 +48,18 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep
} }
} }
@Override
public String saveFile(File file, String filename) {
try {
InputStream in = new FileInputStream(file);
ObjectId id = gridFsTemplate.store(in, filename);
return id.toString();
} catch (Exception e) {
logger.error("存储文件时发生错误!!!", e);
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}
}
@Override @Override
public void deleteFile(String fileId) { public void deleteFile(String fileId) {
Query query = Query.query(Criteria.where("_id").is(fileId)); Query query = Query.query(Criteria.where("_id").is(fileId));
...@@ -68,7 +72,7 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep ...@@ -68,7 +72,7 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep
} }
@Override @Override
public File getFile(String fileId) { public File getFile(String fileId, String suffix) {
Query query = Query.query(Criteria.where("_id").is(fileId)); Query query = Query.query(Criteria.where("_id").is(fileId));
// 查询单个文件 // 查询单个文件
GridFSFile gridFSFile = gridFsTemplate.findOne(query); GridFSFile gridFSFile = gridFsTemplate.findOne(query);
...@@ -81,7 +85,7 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep ...@@ -81,7 +85,7 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep
InputStream inputStream = gridFsResource.getInputStream(); InputStream inputStream = gridFsResource.getInputStream();
byte[] f = getBytes(inputStream); byte[] f = getBytes(inputStream);
File file = new File(gridFSFile.getFilename() + ".png"); File file = new File(gridFSFile.getFilename() + suffix);
FileOutputStream out = new FileOutputStream(file); FileOutputStream out = new FileOutputStream(file);
out.write(f); out.write(f);
out.close(); out.close();
...@@ -102,6 +106,25 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep ...@@ -102,6 +106,25 @@ public class CompanyAuthorizeRepositoryCustomImpl implements CompanyAuthorizeRep
return bos.toByteArray(); return bos.toByteArray();
} }
@Override
public String updateFile(File file, String filename) {
try {
InputStream in = new FileInputStream(file);
Query query = Query.query(Criteria.where("filename").is(filename));
// 查询单个文件
GridFSFile gridFSFile = gridFsTemplate.findOne(query);
ObjectId id;
if (gridFSFile == null)
id = gridFsTemplate.store(in, filename);
else {
gridFsTemplate.delete(query);
id = gridFsTemplate.store(in, filename);
}
in.close();
return id.toString();
} catch (Exception e) {
logger.error("更新文件时发生错误!!!", e);
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
}
}
} }
...@@ -9,6 +9,7 @@ import com.edgec.browserbackend.browser.dto.IpResourceDto; ...@@ -9,6 +9,7 @@ import com.edgec.browserbackend.browser.dto.IpResourceDto;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -60,4 +61,6 @@ public interface AdministratorService { ...@@ -60,4 +61,6 @@ public interface AdministratorService {
PromotionQueryResultDto queryPromotion(Pageable pageable, String username, String promotionCode, String strDate1, String strDate2); PromotionQueryResultDto queryPromotion(Pageable pageable, String username, String promotionCode, String strDate1, String strDate2);
void addWhiteList(String website); void addWhiteList(String website);
File getProxyConfig();
} }
...@@ -368,7 +368,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -368,7 +368,7 @@ public class AccountServiceImpl implements AccountService {
if (account.getPromotion() != null) { if (account.getPromotion() != null) {
int invitedUsers = repository.countByPromotionCodeAndParentIsNull(account.getPromotion().getCode()); int invitedUsers = repository.countByPromotionCodeAndParentIsNull(account.getPromotion().getCode());
String code = account.getPromotion().getCode(); String code = account.getPromotion().getCode();
List<Account> promotes = repository.findByPromotionCode(code); List<Account> promotes = repository.findByPromotionCodeAndParentIsNull(code);
double totalCommission = 0; double totalCommission = 0;
totalCommission = 0; totalCommission = 0;
for (Account promote : promotes) { for (Account promote : promotes) {
...@@ -1142,15 +1142,15 @@ public class AccountServiceImpl implements AccountService { ...@@ -1142,15 +1142,15 @@ public class AccountServiceImpl implements AccountService {
CompanyAuthorize companyAuthorize = companyAuthorizeRepository.findByUsername(username); CompanyAuthorize companyAuthorize = companyAuthorizeRepository.findByUsername(username);
if (companyAuthorize == null) if (companyAuthorize == null)
return null; return null;
File companyLicense = companyAuthorizeRepository.getFile(companyAuthorize.getCompanyLicenseId()); File companyLicense = companyAuthorizeRepository.getFile(companyAuthorize.getCompanyLicenseId(), ".png");
File coporationLicense_Front = companyAuthorizeRepository.getFile(companyAuthorize.getCoporationLicenseFront()); File coporationLicense_Front = companyAuthorizeRepository.getFile(companyAuthorize.getCoporationLicenseFront(), ".png");
File coporationLicense_Back = companyAuthorizeRepository.getFile(companyAuthorize.getCoporationLicenseBack()); File coporationLicense_Back = companyAuthorizeRepository.getFile(companyAuthorize.getCoporationLicenseBack(), ".png");
File agencyLicense_Front = null; File agencyLicense_Front = null;
File agencyLicense_Back = null; File agencyLicense_Back = null;
if (companyAuthorize.getAgencyFront() != null) if (companyAuthorize.getAgencyFront() != null)
agencyLicense_Front = companyAuthorizeRepository.getFile(companyAuthorize.getAgencyFront()); agencyLicense_Front = companyAuthorizeRepository.getFile(companyAuthorize.getAgencyFront(), ".png");
if (companyAuthorize.getAgencyBack() != null) if (companyAuthorize.getAgencyBack() != null)
agencyLicense_Back = companyAuthorizeRepository.getFile(companyAuthorize.getAgencyBack()); agencyLicense_Back = companyAuthorizeRepository.getFile(companyAuthorize.getAgencyBack(), ".png");
try { try {
File tempFile = File.createTempFile("tempFile", "zip"); File tempFile = File.createTempFile("tempFile", "zip");
List<File> files = Arrays.asList(companyLicense, coporationLicense_Front, coporationLicense_Back); List<File> files = Arrays.asList(companyLicense, coporationLicense_Front, coporationLicense_Back);
......
...@@ -10,8 +10,11 @@ import com.edgec.browserbackend.account.repository.*; ...@@ -10,8 +10,11 @@ import com.edgec.browserbackend.account.repository.*;
import com.edgec.browserbackend.account.service.AdministratorService; import com.edgec.browserbackend.account.service.AdministratorService;
import com.edgec.browserbackend.auth.service.UserService; import com.edgec.browserbackend.auth.service.UserService;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode; import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.browser.domain.ProxyConfig;
import com.edgec.browserbackend.browser.repository.IpResourceRepository; import com.edgec.browserbackend.browser.repository.IpResourceRepository;
import com.edgec.browserbackend.browser.repository.ProxyConfigRepository;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import com.edgec.browserbackend.common.commons.utils.DateConverter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -23,6 +26,7 @@ import org.springframework.data.domain.PageRequest; ...@@ -23,6 +26,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.ZoneOffset; import java.time.ZoneOffset;
...@@ -60,6 +64,9 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -60,6 +64,9 @@ public class AdministratorServiceImpl implements AdministratorService {
@Autowired @Autowired
private WhiteSiteRepository whiteSiteRepository; private WhiteSiteRepository whiteSiteRepository;
@Autowired
private ProxyConfigRepository proxyConfigRepository;
@Override @Override
public Administrator createAdministrator(Administrator administrator) { public Administrator createAdministrator(Administrator administrator) {
Administrator administrator1 = new Administrator(); Administrator administrator1 = new Administrator();
...@@ -424,7 +431,7 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -424,7 +431,7 @@ public class AdministratorServiceImpl implements AdministratorService {
promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission()); promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission());
double secondCommission = 0; double secondCommission = 0;
if (finalAccount.getPromotion().isSale() && x.getParent() == null) { if (finalAccount.getPromotion().isSale() && x.getParent() == null) {
List<Account> secondPromotes = accountRepository.findByPromotionCode(x.getPromotion().getCode()); List<Account> secondPromotes = accountRepository.findByPromotionCodeAndParentIsNull(x.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) { if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) { for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndPayMethodInAndTimestampBetween(secondPromote.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime()); List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndPayMethodInAndTimestampBetween(secondPromote.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime());
...@@ -457,6 +464,21 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -457,6 +464,21 @@ public class AdministratorServiceImpl implements AdministratorService {
whiteSite.setWhite(website); whiteSite.setWhite(website);
whiteSiteRepository.save(whiteSite); whiteSiteRepository.save(whiteSite);
} }
@Override
public File getProxyConfig() {
ProxyConfig proxyConfig = null;
if (proxyConfigRepository.count() > 0)
proxyConfig = proxyConfigRepository.findAll().get(0);
if (proxyConfig == null)
return null;
File file = proxyConfigRepository.getFile(proxyConfig.getConfigFileId(), ".cfg");
if (file != null)
return file;
else
return null;
}
} }
......
...@@ -284,7 +284,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -284,7 +284,7 @@ public class PaymentServiceImpl implements PaymentService {
+ "}" + "}"
); );
AlipayTradeQueryResponse response = alipayClient.execute(alipayRequest); AlipayTradeQueryResponse response = alipayClient.execute(alipayRequest);
log.error("ali order status :" + JSONObject.toJSONString(response)); log.info("ali order status :" + JSONObject.toJSONString(response));
if (response.getTradeStatus() == null) { if (response.getTradeStatus() == null) {
result.setPaid(false); result.setPaid(false);
result.setStatus(convertAlipayStatus("WAIT_BUYER_PAY")); result.setStatus(convertAlipayStatus("WAIT_BUYER_PAY"));
...@@ -678,7 +678,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -678,7 +678,7 @@ public class PaymentServiceImpl implements PaymentService {
accountRepository.save(byName); accountRepository.save(byName);
internalOrder.setSucceed(false); internalOrder.setSucceed(false);
userWithdrawRepository.save(internalOrder); userWithdrawRepository.save(internalOrder);
log.error(response.getBody()); log.info(response.getBody());
return false; return false;
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -815,7 +815,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -815,7 +815,7 @@ public class PaymentServiceImpl implements PaymentService {
+ "}" + "}"
); );
AlipayTradeQueryResponse response = alipayClient.execute(alipayRequest); AlipayTradeQueryResponse response = alipayClient.execute(alipayRequest);
log.error("ali order status :" + JSONObject.toJSONString(response)); log.info("ali order status :" + JSONObject.toJSONString(response));
result.setStatus(convertAlipayStatus(response.getTradeStatus())); result.setStatus(convertAlipayStatus(response.getTradeStatus()));
if ("TRADE_SUCCESS".equals(response.getTradeStatus()) || "TRADE_FINISHED".equals(response.getTradeStatus())) { if ("TRADE_SUCCESS".equals(response.getTradeStatus()) || "TRADE_FINISHED".equals(response.getTradeStatus())) {
......
...@@ -33,7 +33,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -33,7 +33,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) throws Exception {
web.ignoring() web.ignoring()
.antMatchers( "/user/authCode", "/user/signUp", .antMatchers( "/user/authCode", "/user/signUp",
"/user/forgot**"); "/user/forgot**", "/0xadministrator/getconfig**");
} }
@Override @Override
......
...@@ -6,6 +6,8 @@ import com.edgec.browserbackend.auth.exception.AuthErrorCode; ...@@ -6,6 +6,8 @@ import com.edgec.browserbackend.auth.exception.AuthErrorCode;
import com.edgec.browserbackend.auth.repository.UserAttemptsLoginRepository; import com.edgec.browserbackend.auth.repository.UserAttemptsLoginRepository;
import com.edgec.browserbackend.auth.repository.UserRepository; import com.edgec.browserbackend.auth.repository.UserRepository;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent; import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent;
...@@ -16,6 +18,8 @@ import java.util.Date; ...@@ -16,6 +18,8 @@ import java.util.Date;
@Component @Component
public class AuthenticationFailureEventListener implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> { public class AuthenticationFailureEventListener implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
private static final Logger log = LoggerFactory.getLogger(AuthenticationFailureEventListener.class);
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
...@@ -30,8 +34,10 @@ public class AuthenticationFailureEventListener implements ApplicationListener<A ...@@ -30,8 +34,10 @@ public class AuthenticationFailureEventListener implements ApplicationListener<A
if (user != null) { if (user != null) {
UserAttemptsLogin userAttempts = userAttemptsLoginRepository.findById(username).orElse(null); UserAttemptsLogin userAttempts = userAttemptsLoginRepository.findById(username).orElse(null);
if (userAttempts != null) { if (userAttempts != null) {
log.error(userAttempts.getAttempts() + "!!!");
if (userAttempts.getDate().getTime() >= (new Date().getTime() - 600000)) { if (userAttempts.getDate().getTime() >= (new Date().getTime() - 600000)) {
int fails = userAttempts.getAttempts(); int fails = userAttempts.getAttempts();
log.error("faile" + fails);
if (fails < 20) if (fails < 20)
saveUserAttemptsLogin(username, fails + 1); saveUserAttemptsLogin(username, fails + 1);
else else
......
...@@ -31,7 +31,7 @@ public class AuthenticationSuccessEventListener implements ApplicationListener<A ...@@ -31,7 +31,7 @@ public class AuthenticationSuccessEventListener implements ApplicationListener<A
if (user != null) { if (user != null) {
UserAttemptsLogin userAttempts = userAttemptsLoginRepository.findById(username).orElse(null); UserAttemptsLogin userAttempts = userAttemptsLoginRepository.findById(username).orElse(null);
if(userAttempts != null) { if(userAttempts != null) {
if (userAttempts.getAttempts() >= 5) { if (userAttempts.getAttempts() >= 20) {
if (userAttempts.getDate().getTime() >= (new Date().getTime() - 600000)) if (userAttempts.getDate().getTime() >= (new Date().getTime() - 600000))
throw new ClientRequestException(AuthErrorCode.LOGINTIMESEXCEEDED, "Login times exceeded"); throw new ClientRequestException(AuthErrorCode.LOGINTIMESEXCEEDED, "Login times exceeded");
} else if (userAttempts.getAttempts() != 0) { } else if (userAttempts.getAttempts() != 0) {
......
package com.edgec.browserbackend.browser.domain;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "proxyconfig")
public class ProxyConfig {
private long timestamp;
private String configFileId;
public long getTimestamp() {
return timestamp;
}
public void setConfigFileId(String configFileId) {
this.configFileId = configFileId;
}
public String getConfigFileId() {
return configFileId;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
}
package com.edgec.browserbackend.browser.repository;
import com.edgec.browserbackend.account.repository.FileRepository;
import com.edgec.browserbackend.browser.domain.ProxyConfig;
import org.springframework.data.mongodb.repository.MongoRepository;
public interface ProxyConfigRepository extends MongoRepository<ProxyConfig, String>, FileRepository, ProxyConfigRepositoryCustom {
}
package com.edgec.browserbackend.browser.repository;
import java.io.File;
public interface ProxyConfigRepositoryCustom {
boolean updateProxy(File file, long time);
}
package com.edgec.browserbackend.browser.repository;
import com.edgec.browserbackend.account.repository.FileRepository;
import com.edgec.browserbackend.account.repository.FileRepositoryImpl;
import com.edgec.browserbackend.browser.domain.ProxyConfig;
import com.edgec.browserbackend.browser.domain.UserShop;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Update;
import java.io.File;
import static org.springframework.data.mongodb.core.query.Criteria.where;
public class ProxyConfigRepositoryCustomImpl implements ProxyConfigRepositoryCustom {
@Autowired
private FileRepositoryImpl fileRepository;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public boolean updateProxy(File file, long time) {
String fileId = fileRepository.updateFile(file, "3proxy");
Document doc = new Document();
BasicQuery basicQuery = new BasicQuery(doc);
Update update = new Update();
update.set("configFileId", fileId).set("timestamp", time);
UpdateResult operation = mongoTemplate.upsert(basicQuery, update, ProxyConfig.class);
if (operation.getModifiedCount() < 1)
return false;
else
return true;
}
}
...@@ -52,6 +52,35 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -52,6 +52,35 @@ public class IpResourceServiceImpl implements IpResourceService {
private static String TESTURL = "http://112.74.13.2"; private static String TESTURL = "http://112.74.13.2";
private static String USERNAME = "fangguanlianbrowser"; private static String USERNAME = "fangguanlianbrowser";
public static List<String> region = Arrays.asList(
"asiapa",
"hongkong",
"japan",
"s-korea",
"us",
"malaysia",
"yajiada",
"singapore",
"australia",
"germany",
"uk",
"brazil",
"moscow",
"canada",
"france",
"sweden",
"s-korea",
"india",
"meast",
"brazil",
"virginia",
"ohio",
"california",
"oregon",
"ireland",
"london",
"ireland");
private static List<String> port = Arrays.asList("20000", "20001"); private static List<String> port = Arrays.asList("20000", "20001");
private static List<String> protocol = Arrays.asList("socks5", "proxy"); private static List<String> protocol = Arrays.asList("socks5", "proxy");
...@@ -222,6 +251,8 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -222,6 +251,8 @@ public class IpResourceServiceImpl implements IpResourceService {
} else if (ipResourceRequestDto.getVendor().equals("own")) { } else if (ipResourceRequestDto.getVendor().equals("own")) {
if (ipResourceRequestDto.getAddr() == null || ipResourceRequestDto.getAddr().size() == 0) if (ipResourceRequestDto.getAddr() == null || ipResourceRequestDto.getAddr().size() == 0)
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
if (StringUtils.isBlank(ipResourceRequestDto.getAddr().get(0)))
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
ipResource.setAddr(ipResourceRequestDto.getAddr().get(0)); ipResource.setAddr(ipResourceRequestDto.getAddr().get(0));
ipResource.setIpType(IpType.OWN); ipResource.setIpType(IpType.OWN);
ipResource.setVendor(Vendor.valueOf(ipResourceRequestDto.getVendor())); ipResource.setVendor(Vendor.valueOf(ipResourceRequestDto.getVendor()));
...@@ -255,6 +286,11 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -255,6 +286,11 @@ public class IpResourceServiceImpl implements IpResourceService {
if (account.getParent() != null) if (account.getParent() != null)
ipResource.setUserParent(account.getParent()); ipResource.setUserParent(account.getParent());
ipResource.setRegion(ipResourceRequestDto.getRegion()); ipResource.setRegion(ipResourceRequestDto.getRegion());
if (StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion())) {
ipResource.setProxyUsername(ipResource.getAddr());
ipResource.setProxyPassword(genRandom(3, 12));
ipResource.setSpecialLine(true);
}
ipResource.setRegionCn(ipResourceRequestDto.getRegionCn()); ipResource.setRegionCn(ipResourceRequestDto.getRegionCn());
ipResource.setProtocol(protocol); ipResource.setProtocol(protocol);
ipResource.setPassword(password); ipResource.setPassword(password);
...@@ -660,6 +696,11 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -660,6 +696,11 @@ public class IpResourceServiceImpl implements IpResourceService {
if (StringUtils.isNotBlank(ipResourceUpdateDto.getAddr())) { if (StringUtils.isNotBlank(ipResourceUpdateDto.getAddr())) {
ipResource.setAddr(ipResourceUpdateDto.getAddr()); ipResource.setAddr(ipResourceUpdateDto.getAddr());
} }
if (StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion())) {
ipResource.setProxyUsername(ipResource.getAddr());
ipResource.setProxyPassword(genRandom(3, 12));
ipResource.setSpecialLine(true);
}
ipResource.setStatus(ipResourceUpdateDto.getStatus()); ipResource.setStatus(ipResourceUpdateDto.getStatus());
ipResourceRepository.save(ipResource); ipResourceRepository.save(ipResource);
} }
...@@ -725,34 +766,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -725,34 +766,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override @Override
public void setSpecialLine() { public void setSpecialLine() {
List<IpResource> ipResources = ipResourceRepository.findByRegionInAndIsDeleted(Arrays.asList( List<IpResource> ipResources = ipResourceRepository.findByRegionInAndIsDeleted(region, false);
"asiapa",
"hongkong",
"japan",
"s-korea",
"us",
"malaysia",
"yajiada",
"singapore",
"australia",
"germany",
"uk",
"brazil",
"moscow",
"canada",
"france",
"sweden",
"s-korea",
"india",
"meast",
"brazil",
"virginia",
"ohio",
"california",
"oregon",
"ireland",
"london",
"ireland"), false);
for (IpResource ipResource : ipResources) { for (IpResource ipResource : ipResources) {
ipResource.setProxyUsername(ipResource.getAddr()); ipResource.setProxyUsername(ipResource.getAddr());
ipResource.setProxyPassword(genRandom(3, 12)); ipResource.setProxyPassword(genRandom(3, 12));
......
...@@ -26,6 +26,9 @@ import java.util.Map; ...@@ -26,6 +26,9 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import static com.edgec.browserbackend.browser.service.Impl.IpResourceServiceImpl.genRandom;
import static com.edgec.browserbackend.browser.service.Impl.IpResourceServiceImpl.region;
@Component @Component
public class BrowserTask { public class BrowserTask {
...@@ -123,6 +126,11 @@ public class BrowserTask { ...@@ -123,6 +126,11 @@ public class BrowserTask {
ipResource.setAddr(x.getIp()); ipResource.setAddr(x.getIp());
ipResource.setStatus(3); ipResource.setStatus(3);
ipResource.setValidTime(Instant.parse(x.getValidTill()).toEpochMilli()); ipResource.setValidTime(Instant.parse(x.getValidTill()).toEpochMilli());
if (StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion())) {
ipResource.setProxyUsername(ipResource.getAddr());
ipResource.setProxyPassword(genRandom(3, 12));
ipResource.setSpecialLine(true);
}
ipResourceRepository.save(ipResource); ipResourceRepository.save(ipResource);
} else { } else {
log.error("no ipResource"); log.error("no ipResource");
......
...@@ -6,6 +6,7 @@ import com.edgec.browserbackend.account.repository.AccountRepository; ...@@ -6,6 +6,7 @@ import com.edgec.browserbackend.account.repository.AccountRepository;
import com.edgec.browserbackend.browser.domain.IpResource; import com.edgec.browserbackend.browser.domain.IpResource;
import com.edgec.browserbackend.browser.repository.IpResourceRepository; import com.edgec.browserbackend.browser.repository.IpResourceRepository;
import com.edgec.browserbackend.common.commons.utils.SmsUtils; import com.edgec.browserbackend.common.commons.utils.SmsUtils;
import net.javacrumbs.shedlock.core.SchedulerLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -26,6 +27,7 @@ public class ExpireSoonWarn { ...@@ -26,6 +27,7 @@ public class ExpireSoonWarn {
private IpResourceRepository ipResourceRepository; private IpResourceRepository ipResourceRepository;
@Scheduled(cron = "0 0 9 * * ?") @Scheduled(cron = "0 0 9 * * ?")
@SchedulerLock(name = "ExpireSoonWarnsendMessages", lockAtMostForString = "PT600S", lockAtLeastForString = "PT600S")
public void sendMessages() { public void sendMessages() {
this.sendExpiredIpAccount(0); this.sendExpiredIpAccount(0);
this.sendExpiredIpAccount(7); this.sendExpiredIpAccount(7);
......
...@@ -29,13 +29,13 @@ public class PromotionTask { ...@@ -29,13 +29,13 @@ public class PromotionTask {
@Autowired @Autowired
private UserPrePaidBillingRepository userPrePaidBillingRepository; private UserPrePaidBillingRepository userPrePaidBillingRepository;
@SchedulerLock(name = "transferExpiredScalingGroups", lockAtLeastForString = "PT1H", lockAtMostForString = "PT2H") @SchedulerLock(name = "countGift", lockAtLeastForString = "PT1H", lockAtMostForString = "PT2H")
@Scheduled(cron = "0 0 1 1 * ?") @Scheduled(cron = "0 0 1 1 * ?")
public void countGift() { public void countGift() {
List<Account> accounts = accountRepository.findByParentIsNull(); List<Account> accounts = accountRepository.findByParentIsNull();
for (Account account : accounts) { for (Account account : accounts) {
String code = account.getPromotion().getCode(); String code = account.getPromotion().getCode();
List<Account> promotes = accountRepository.findByPromotionCode(code); List<Account> promotes = accountRepository.findByPromotionCodeAndParentIsNull(code);
double totalCommission = 0; double totalCommission = 0;
double secondCommission = 0; double secondCommission = 0;
for (Account promote : promotes) { for (Account promote : promotes) {
...@@ -44,7 +44,7 @@ public class PromotionTask { ...@@ -44,7 +44,7 @@ public class PromotionTask {
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2,3));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
if (account.getPromotion().isSale() && promote.getParent() == null) { if (account.getPromotion().isSale() && promote.getParent() == null) {
List<Account> secondPromotes = accountRepository.findByPromotionCode(promote.getPromotion().getCode()); List<Account> secondPromotes = accountRepository.findByPromotionCodeAndParentIsNull(promote.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) { if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) { for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(), List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(),
...@@ -67,13 +67,13 @@ public class PromotionTask { ...@@ -67,13 +67,13 @@ public class PromotionTask {
} }
} }
@SchedulerLock(name = "transferExpiredScalingGroups", lockAtLeastForString = "PT1H", lockAtMostForString = "PT2H") @SchedulerLock(name = "countCommission", lockAtLeastForString = "PT1H", lockAtMostForString = "PT2H")
@Scheduled(cron = "0 0 1 * * ?") @Scheduled(cron = "0 0 1 * * ?")
public void countCommission() { public void countCommission() {
List<Account> accounts = accountRepository.findByParentIsNull(); List<Account> accounts = accountRepository.findByParentIsNull();
for (Account account : accounts) { for (Account account : accounts) {
String code = account.getPromotion().getCode(); String code = account.getPromotion().getCode();
List<Account> promotes = accountRepository.findByPromotionCode(code); List<Account> promotes = accountRepository.findByPromotionCodeAndParentIsNull(code);
double totalCommission = 0; double totalCommission = 0;
double secondCommission = 0; double secondCommission = 0;
for (Account promote : promotes) { for (Account promote : promotes) {
...@@ -82,7 +82,7 @@ public class PromotionTask { ...@@ -82,7 +82,7 @@ public class PromotionTask {
YearMonth.now().getMonthValue(), Arrays.asList(1,2,3)); YearMonth.now().getMonthValue(), Arrays.asList(1,2,3));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum(); totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
if (account.getPromotion().isSale() && promote.getParent() == null) { if (account.getPromotion().isSale() && promote.getParent() == null) {
List<Account> secondPromotes = accountRepository.findByPromotionCode(promote.getPromotion().getCode()); List<Account> secondPromotes = accountRepository.findByPromotionCodeAndParentIsNull(promote.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) { if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) { for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(), List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndYearAndMonthAndPayMethodIn(secondPromote.getName(),
......
package com.edgec.browserbackend.browser.task; package com.edgec.browserbackend.browser.task;
import com.edgec.browserbackend.account.repository.AccountRepository; import com.edgec.browserbackend.account.repository.AccountRepository;
import com.edgec.browserbackend.account.repository.CompanyAuthorizeRepository;
import com.edgec.browserbackend.auth.domain.mongo.MongoOAuth2AccessToken; import com.edgec.browserbackend.auth.domain.mongo.MongoOAuth2AccessToken;
import com.edgec.browserbackend.auth.repository.mongo.MongoOAuth2AccessTokenRepository; import com.edgec.browserbackend.auth.repository.mongo.MongoOAuth2AccessTokenRepository;
import com.edgec.browserbackend.browser.domain.IpResource; import com.edgec.browserbackend.browser.domain.IpResource;
import com.edgec.browserbackend.browser.domain.ProxyConfig;
import com.edgec.browserbackend.browser.domain.SpecialLine; import com.edgec.browserbackend.browser.domain.SpecialLine;
import com.edgec.browserbackend.browser.repository.IpResourceRepository; import com.edgec.browserbackend.browser.repository.IpResourceRepository;
import com.edgec.browserbackend.browser.repository.ProxyConfigRepository;
import com.edgec.browserbackend.browser.repository.SpecialLineRepository; import com.edgec.browserbackend.browser.repository.SpecialLineRepository;
import com.edgec.browserbackend.browser.service.Impl.IpResourceServiceImpl; import net.javacrumbs.shedlock.core.SchedulerLock;
import com.edgec.browserbackend.common.commons.utils.RemoteShellExecutor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -38,17 +40,28 @@ public class Set3proxyTask { ...@@ -38,17 +40,28 @@ public class Set3proxyTask {
@Autowired @Autowired
private SpecialLineRepository specialLineRepository; private SpecialLineRepository specialLineRepository;
@Autowired
private ProxyConfigRepository proxyConfigRepository;
@Scheduled(cron = "0 0/10 * * * ?") @Scheduled(cron = "0 0/10 * * * ?")
@SchedulerLock(name = "proxyTask", lockAtLeastFor = 60*1000*5, lockAtMostFor = 60*1000*9)
public void set3proxy() { public void set3proxy() {
long validTime = Instant.now().minusSeconds(43200).toEpochMilli(); long validTime = Instant.now().minusSeconds(43200).toEpochMilli();
// List<String> tokenUsernames = mongoOAuth2AccessTokenRepository.findByCreatedAtGreaterThan(validTime).stream().map(MongoOAuth2AccessToken::getUsername).collect(Collectors.toList()); if (proxyConfigRepository.count() > 0) {
// List<String> accountParents = accountRepository.findByNameIn(tokenUsernames).stream().map(x -> x.getParent() == null ? x.getName() : x.getParent()).distinct().collect(Collectors.toList()); ProxyConfig proxyConfig = proxyConfigRepository.findAll().get(0);
List<IpResource> ipResources = ipResourceRepository.findBySpecialLine(true); if (Instant.now().toEpochMilli() < proxyConfig.getTimestamp())
File file = new File("3proxy.cfg"); return;
}
List<String> tokenUsernames = mongoOAuth2AccessTokenRepository.findByCreatedAtGreaterThan(validTime).stream().map(MongoOAuth2AccessToken::getUsername).collect(Collectors.toList());
List<String> accountParents = accountRepository.findByNameIn(tokenUsernames).stream().map(x -> x.getParent() == null ? x.getName() : x.getParent()).distinct().collect(Collectors.toList());
List<IpResource> ipResources = ipResourceRepository.findByOwnerInAndSpecialLine(accountParents, true);
// List<IpResource> ipResources = ipResourceRepository.findBySpecialLine(true);
File file = new File("3proxy " + Instant.now().toEpochMilli());
SpecialLine specialLine = specialLineRepository.findAll().get(0); SpecialLine specialLine = specialLineRepository.findAll().get(0);
try { try {
file.delete(); file.delete();
file.createNewFile(); file.createNewFile();
FileWriter fileWriter =new FileWriter(file, true); FileWriter fileWriter =new FileWriter(file, true);
BufferedWriter bw = new BufferedWriter(fileWriter); BufferedWriter bw = new BufferedWriter(fileWriter);
bw.write("daemon\nlog /var/log/3proxy.log D\nrotate 30\n"); bw.write("daemon\nlog /var/log/3proxy.log D\nrotate 30\n");
...@@ -64,16 +77,27 @@ public class Set3proxyTask { ...@@ -64,16 +77,27 @@ public class Set3proxyTask {
for (IpResource ipResource : ipResources) { for (IpResource ipResource : ipResources) {
if (StringUtils.isNotBlank(ipResource.getAddr())) { if (StringUtils.isNotBlank(ipResource.getAddr())) {
bw.write("allow " + ipResource.getProxyUsername() + "\n"); bw.write("allow " + ipResource.getProxyUsername() + "\n");
bw.write("parent 1000 " + specialLine.getProxyProtocol().get(0) + " " + ipResource.getAddr() + " " + ipResource.getPort().get(1) + " fangguanlianbrowser " + ipResource.getPassword() + "\n"); bw.write("parent 1000 http " + ipResource.getAddr() + " " + ipResource.getPort().get(1) + " fangguanlianbrowser " + ipResource.getPassword() + "\n");
} }
} }
bw.write("\nallow none\nproxy -p20004\nsocks-p20005"); bw.write("\nallow none\nproxy -p20004\nsocks -p20005\n");
bw.flush(); bw.flush();
bw.close(); bw.close();
log.info("成功写入文件"); log.info("成功写入文件");
// RemoteShellExecutor remoteShellExecutor = new RemoteShellExecutor(specialLine.getIp(), specialLine.getUsername(), specialLine.getPassword()); long nowtime = Instant.now().toEpochMilli();
// remoteShellExecutor.transferFile("3proxy.cfg", "/root"); if (proxyConfigRepository.count() > 0) {
// remoteShellExecutor.execCommand("cd /root && sh restart.sh"); ProxyConfig proxyConfig = proxyConfigRepository.findAll().get(0);
if (nowtime < proxyConfig.getTimestamp()) {
file.delete();
return;
} else {
proxyConfigRepository.updateProxy(file, nowtime);
file.delete();
}
} else {
proxyConfigRepository.updateProxy(file, nowtime);
file.delete();
}
} catch (Exception e) { } catch (Exception e) {
log.error("出错了"); log.error("出错了");
log.error(e.getMessage()); log.error(e.getMessage());
......
...@@ -319,8 +319,8 @@ public class RemoteShellExecutor { ...@@ -319,8 +319,8 @@ public class RemoteShellExecutor {
} }
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
RemoteShellExecutor executor = new RemoteShellExecutor("47.112.253.229", "root", "hIB4EbOcnkF5aA1"); // RemoteShellExecutor executor = new RemoteShellExecutor("47.112.253.229", "root", "hIB4EbOcnkF5aA1");
executor.transferFile("3proxy.cfg", "/root"); // executor.transferFile("3proxy.cfg", "/root");
executor.execCommand("cd /root && sh restart.sh"); // executor.execCommand("cd /root && sh restart.sh");
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment