Compare commits

..

5 Commits

@ -0,0 +1 @@
package main

@ -0,0 +1,90 @@
package aeschiper
import (
"errors"
"fmt"
"io"
"os"
"b612.me/starcrypto"
"b612.me/staros"
)
func EncodeStr(str, key string) string {
ensdata := starcrypto.AesEncryptCFBNoBlock([]byte(str), starcrypto.Md5([]byte(key)))
return starcrypto.Base91EncodeToString(ensdata)
}
func DecodeStr(str, key string) string {
strtmp := starcrypto.Base91DecodeString(str)
str = string(strtmp)
return string(starcrypto.AesDecryptCFBNoBlock([]byte(str), starcrypto.Md5([]byte(key))))
}
func EncodeFile(fpath, out, key string) error {
if !staros.Exists(fpath) {
return errors.New("SrcFile Not Exists")
}
fpsrc, err := os.Open(fpath)
if err != nil {
return err
}
defer fpsrc.Close()
fpdst, err := os.Create(out)
if err != nil {
return err
}
defer fpdst.Close()
bufsize := 1024 * 1024 //1MB
stat, _ := fpsrc.Stat()
buf := make([]byte, bufsize)
sumAll := 0
for {
n, err := fpsrc.Read(buf)
if err != nil && err != io.EOF {
return err
}
fmt.Print("已完成:%.2f%%\r", float64(sumAll)/float64(stat.Size())*100)
encodeBytes := starcrypto.AesEncryptCFBNoBlock(buf[:n], starcrypto.Md5([]byte(key)))
fpdst.Write(encodeBytes)
if err == io.EOF {
fmt.Print("已完成100%% \n")
break
}
}
return nil
}
func DecodeFile(fpath, out, key string) error {
if !staros.Exists(fpath) {
return errors.New("SrcFile Not Exists")
}
fpsrc, err := os.Open(fpath)
if err != nil {
return err
}
defer fpsrc.Close()
fpdst, err := os.Create(out)
if err != nil {
return err
}
defer fpdst.Close()
bufsize := 1024 * 1024 //1MB
stat, _ := fpsrc.Stat()
buf := make([]byte, bufsize)
sumAll := 0
for {
n, err := fpsrc.Read(buf)
if err != nil && err != io.EOF {
return err
}
fmt.Print("已完成:%.2f%%\r", float64(sumAll)/float64(stat.Size())*100)
encodeBytes := starcrypto.AesDecryptCFBNoBlock(buf[:n], starcrypto.Md5([]byte(key)))
fpdst.Write(encodeBytes)
if err == io.EOF {
fmt.Print("已完成100%% \n")
break
}
}
return nil
}

@ -0,0 +1,14 @@
package aeschiper
import (
"fmt"
"testing"
)
func Test_EncodeStr(t *testing.T) {
fmt.Println(EncodeStr("我喜欢你", "sakurasaiteruyogugugug"))
}
func Test_DecodeStr(t *testing.T) {
fmt.Println(DecodeStr("Z_8aILbog@Kjm$P", "sakurasaiteruyogugugug"))
}

@ -0,0 +1,78 @@
package main
import (
"io"
"os"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var attachcmd = &cobra.Command{
Use: "attach",
Short: "合并多个文件",
Long: "合并多个文件",
Run: func(this *cobra.Command, args []string) {
src, _ := this.Flags().GetStringArray("src")
out, _ := this.Flags().GetString("out")
if len(src) < 2 || out == "" {
starlog.Criticalln("请输入至少2个输入路径一个输出路径")
os.Exit(1)
}
os.Exit(runAttach(src, out))
},
}
func runAttach(src []string, out string) int {
fpOut, err := os.Create(out)
if err != nil {
starlog.Errorln("Err:无法创建输出文件!", err)
return 2
}
defer fpOut.Close()
for _, file := range src {
fpFile, err := os.OpenFile(file, os.O_RDONLY, 0644)
if err != nil {
starlog.Errorln("Err:Cannot Openfile:", err)
return 3
}
stats, err := fpFile.Stat()
if err != nil {
starlog.Errorln("Err:Cannot Get File Stats:", err)
return 4
}
if stats.Size() == 0 {
starlog.Warningf("文件:%s为空文件跳过\n", stats.Name())
continue
}
buf := make([]byte, 65535)
sumAll := 0
for {
n, err := fpFile.Read(buf)
if err != nil && err != io.EOF {
starlog.Errorln("Err:Error Occured While ReadFile:", err)
fpFile.Close()
return 5
}
sumAll += n
_, errW := fpOut.Write(buf[:n])
if errW != nil {
starlog.Errorln("Error While Write Data to OutFile", errW)
return 6
}
starlog.StdPrintf([]starlog.Attr{starlog.FgGreen}, "文件%s已完成%.2f%%\r", stats.Name(), (float64(sumAll) / float64(stats.Size()) * 100.0000))
if err == io.EOF {
starlog.StdPrintf([]starlog.Attr{starlog.FgGreen}, "文件:%v已完成100.00%% \n", stats.Name())
fpFile.Close()
break
}
}
}
starlog.StdPrintln([]starlog.Attr{starlog.FgGreen}, "Ok!文件合并完成")
return 0
}
func init() {
attachcmd.Flags().StringArrayP("src", "s", []string{}, "源文件路径")
attachcmd.Flags().StringP("out", "o", "", "输出文件路径")
}

@ -1,9 +1,9 @@
package tools
package main
import (
"fmt"
"b612.me/starainrt"
"b612.me/starcrypto"
"b612.me/starlog"
"github.com/spf13/cobra"
)
@ -28,21 +28,20 @@ var b64cmd = &cobra.Command{
fmt.Printf("已处理:%f%%\r", pect)
}
}
cry := new(starainrt.StarCrypto)
if ok {
path, _ := this.Flags().GetString("path")
if !de {
err = cry.Base64EncodeFile(args[0], path, shell)
err = starcrypto.Base64EncodeFile(args[0], path, shell)
} else {
err = cry.Base64DecodeFile(args[0], path, shell)
err = starcrypto.Base64DecodeFile(args[0], path, shell)
}
} else {
if !de {
data := cry.Base64Encode([]byte(args[0]))
data := starcrypto.Base64Encode([]byte(args[0]))
fmt.Println(data)
} else {
var data []byte
data, err = cry.Base64Decode(args[0])
data, err = starcrypto.Base64Decode(args[0])
fmt.Println(string(data))
}
}
@ -57,5 +56,4 @@ func init() {
b64cmd.Flags().BoolP("file", "f", false, "base64处理文件")
b64cmd.Flags().StringP("path", "p", "./b64.encode", "指定处理地址,默认为./b64.encode")
b64cmd.Flags().BoolP("decode", "d", false, "base64解码")
Maincmd.AddCommand(b64cmd)
}

@ -1,9 +0,0 @@
package main
import (
"Victorique/vtqe/tools"
)
func main() {
tools.Maincmd.Execute()
}

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -168,7 +168,6 @@ var curlcmd = &cobra.Command{
}
func init() {
Maincmd.AddCommand(curlcmd)
curlcmd.Flags().StringP("output", "o", "", "写入文件而不是标准输出")
curlcmd.Flags().StringP("data", "d", "", "http postdata数据")
curlcmd.Flags().StringP("file", "f", "", "上传文件的地址")

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -44,5 +44,4 @@ func init() {
detachcmd.Flags().StringP("dst", "d", "", "目标文件路径1")
detachcmd.Flags().StringP("out", "o", "", "目标文件路径2")
detachcmd.Flags().IntP("num", "n", 0, "分割开始字节")
Maincmd.AddCommand(detachcmd)
}

@ -1,4 +1,4 @@
package tools
package main
import (
"log"
@ -11,6 +11,7 @@ import (
var ports int
var username, pwd string
var path, ip string
// ftpCmd represents the ftp command
var ftpcmd = &cobra.Command{
@ -41,7 +42,6 @@ var ftpcmd = &cobra.Command{
}
func init() {
Maincmd.AddCommand(ftpcmd)
ftpcmd.Flags().IntVarP(&ports, "port", "p", 21, "监听端口")
ftpcmd.Flags().StringVarP(&ip, "ip", "i", "0.0.0.0", "监听地址")
ftpcmd.Flags().StringVarP(&username, "user", "u", "1", "用户名默认为1")

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -49,5 +49,4 @@ func init() {
gencmd.Flags().IntP("num", "n", 1024, "生成的文件大小")
gencmd.Flags().IntP("cap", "c", 1048576, "bufcap大小")
gencmd.MarkFlagRequired("num")
Maincmd.AddCommand(gencmd)
}

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -67,5 +67,4 @@ func init() {
hashcmd.Flags().Bool("sha256", false, "进行SHA256校验")
hashcmd.Flags().Bool("sha224", false, "进行SHA224校验")
hashcmd.Flags().Bool("sha1", false, "进行SHA1校验")
Maincmd.AddCommand(hashcmd)
}

@ -0,0 +1,93 @@
package main
import (
"Victorique/vtqe/httpserver"
"os"
"os/signal"
"syscall"
"b612.me/starlog"
"b612.me/staros"
"github.com/spf13/cobra"
)
var httpPort, httpIP, httpPath, httpBasicAuth, httpCertKey, logPath, httpIndexFile string
var doUpload, daemon, httpStopMime bool
func init() {
httpcmd.Flags().StringVarP(&httpPort, "port", "p", "80", "监听端口")
httpcmd.Flags().StringVarP(&httpIP, "ip", "i", "0.0.0.0", "监听ip")
httpcmd.Flags().StringVarP(&httpPath, "folder", "f", "./", "本地文件地址")
httpcmd.Flags().BoolVarP(&doUpload, "upload", "u", false, "是否开启文件上传")
httpcmd.Flags().BoolVarP(&daemon, "daemon", "d", false, "以后台进程运行")
httpcmd.Flags().StringVarP(&httpBasicAuth, "auth", "a", "", "HTTP BASIC AUTH认证(用户名:密码)")
httpcmd.Flags().StringVarP(&httpIndexFile, "index", "n", "", "Index文件名如index.html")
httpcmd.Flags().StringVarP(&logPath, "log", "l", "", "log地址")
httpcmd.Flags().StringVarP(&httpCertKey, "cert", "c", "", "TLS证书路径用:分割证书与密钥")
httpcmd.Flags().BoolVarP(&httpStopMime, "disablemime", "m", false, "停止解析MIME全部按下载文件处理")
httpcmd.Flags().Bool("daeapplied", false, "")
httpcmd.Flags().MarkHidden("daeapplied")
}
// httpCmd represents the http command
var httpcmd = &cobra.Command{
Use: "http",
Short: "HTTP文件服务器",
Long: `HTTP文件服务器`,
Run: func(cmd *cobra.Command, args []string) {
apply, _ := cmd.Flags().GetBool("daeapplied")
if daemon && !apply {
nArgs := append(os.Args[1:], "--daeapplied")
pid, err := staros.Daemon(os.Args[0], nArgs...)
if err != nil {
starlog.Criticalln("Daemon Error:", err)
os.Exit(1)
}
starlog.StdPrintf([]starlog.Attr{starlog.FgGreen}, "Success,PID=%v\n", pid)
return
}
err := run()
if err != nil {
starlog.Errorln("Http Server Closed by Errors")
os.Exit(4)
}
starlog.Infoln("Http Server Closed Normally")
return
},
}
func run() error {
if logPath != "" {
if !staros.Exists(logPath) {
err := starlog.SetLogFile(logPath)
if err != nil {
starlog.Errorln("Create LogFile Failed:", err)
os.Exit(2)
}
defer starlog.Close()
} else {
logFp, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND, 0755)
if err != nil {
starlog.Errorln("Create LogFile Failed:", err)
os.Exit(2)
}
defer logFp.Close()
starlog.Std.SwitchOut(logFp)
}
}
stopChan := make(chan os.Signal, 1)
overChan := make(chan error)
signal.Notify(stopChan, syscall.SIGINT, syscall.SIGKILL)
go func(stop chan<- error) {
err := httpserver.RunHttpServer(httpIP, httpPort, httpBasicAuth, httpPath, httpCertKey, vtqe_version, httpIndexFile, doUpload, httpStopMime)
stop <- err
}(overChan)
select {
case <-stopChan:
return nil
case err := <-overChan:
return err
}
}

@ -1,7 +1,8 @@
package tools
package httpserver
import (
"encoding/base64"
"errors"
"fmt"
"io"
"io/ioutil"
@ -11,90 +12,50 @@ import (
"strconv"
"strings"
"b612.me/starainrt"
"b612.me/starcrypto"
"b612.me/starlog"
"github.com/spf13/cobra"
"b612.me/staros"
)
var port, ip, path string
var up bool
var basicAuth, certKey string
type TraceHandler struct {
h http.Handler
}
func init() {
httpcmd.Flags().StringVarP(&port, "port", "p", "80", "监听端口")
httpcmd.Flags().StringVarP(&ip, "ip", "i", "0.0.0.0", "监听ip")
httpcmd.Flags().StringVarP(&path, "folder", "f", "./", "本地文件地址")
httpcmd.Flags().BoolVarP(&up, "upload", "u", false, "是否开启文件上传")
httpcmd.Flags().StringVarP(&basicAuth, "auth", "a", "", "HTTP BASIC AUTH认证(用户名:密码)")
httpcmd.Flags().StringVarP(&certKey, "cert", "c", "", "TLS证书路径用:分割证书与密钥")
Maincmd.AddCommand(httpcmd)
}
// httpCmd represents the http command
var httpcmd = &cobra.Command{
Use: "http",
Short: "HTTP文件服务器",
Long: `HTTP文件服务器`,
Run: func(cmd *cobra.Command, args []string) {
var err error
http.HandleFunc("/", httplisten)
path, _ = filepath.Abs(path)
starlog.Infoln("Listening On Port:" + port)
if up {
starlog.Infoln("upload is openned,path is /vtqeupload1127")
http.HandleFunc("/vtqeupload1127", uploadfile)
}
if certKey == "" {
err = http.ListenAndServe(ip+":"+port, nil)
} else {
certs := strings.Split(certKey, ":")
if len(certs) != 2 {
starlog.Criticalln("证书不正确!")
return
}
err = http.ListenAndServeTLS(ip+":"+port, certs[0], certs[1], nil)
}
if err != nil {
starlog.Criticalln("Error:" + err.Error())
}
},
type VtqeHttpServer struct {
basicAuth string
path string
upload bool
version string
indexFile string
stopMime bool
}
func uploadfile(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.Write([]byte("USE POST METHOD!"))
return
func RunHttpServer(listenIp, port, auth, folderPath, certKey, version, indexFile string, doUpload, stopMime bool) error {
var err error
var vtqe VtqeHttpServer = VtqeHttpServer{auth, folderPath, doUpload, version, indexFile, stopMime}
http.HandleFunc("/", vtqe.httpListen)
starlog.Noticeln("Listening On " + listenIp + ":" + port)
if doUpload {
starlog.Noticeln("upload is openned,path is /vtqeupload1127")
http.HandleFunc("/vtqeupload1127", vtqe.uploadFile)
}
r.ParseMultipartForm(10485760)
file, handler, err := r.FormFile("victorique")
if err != nil {
starlog.Errorln(err)
w.WriteHeader(502)
w.Write([]byte(err.Error()))
return
if certKey == "" {
err = http.ListenAndServe(listenIp+":"+port, nil)
} else {
certs := strings.Split(certKey, ":")
if len(certs) != 2 {
starlog.Criticalln("证书不正确!")
return errors.New("ZSBZQ")
}
err = http.ListenAndServeTLS(listenIp+":"+port, certs[0], certs[1], nil)
}
defer file.Close()
starlog.Noticef("Upload %s From %s\n", handler.Filename, r.RemoteAddr)
fmt.Fprintf(w, `<html><body><p>%v</p><h2><a href="./vtqeupload1127/web">Return To Web Page</a></h2></body></html>`, handler.Header)
os.Mkdir("./vtqeupload1127", 0755)
f, err := os.OpenFile("./vtqeupload1127/"+handler.Filename, os.O_WRONLY|os.O_CREATE, 0755)
if err != nil {
starlog.Errorln(err)
return
starlog.Criticalln("Error:" + err.Error())
return err
}
defer f.Close()
io.Copy(f, file)
return nil
}
func httplisten(w http.ResponseWriter, r *http.Request) {
func (v VtqeHttpServer) httpListen(w http.ResponseWriter, r *http.Request) {
log := starlog.Std.NewFlag()
w.Header().Set("Server", "Vicorique")
w.Header().Set("Server", "Victorique")
w.Header().Set("Powered", "B612.ME")
write401 := func() {
w.Header().Set("WWW-Authenticate", ` Basic realm="Please Enter Passwd"`)
@ -108,14 +69,14 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
</body>
</html>`))
}
if basicAuth != "" {
if v.basicAuth != "" {
authHeader := strings.TrimSpace(r.Header.Get("Authorization"))
if len(authHeader) == 0 {
log.Noticeln("No Authed! Get Path is", r.URL.Path, r.RemoteAddr)
write401()
return
} else {
userAuth := base64.StdEncoding.EncodeToString([]byte(basicAuth))
userAuth := base64.StdEncoding.EncodeToString([]byte(v.basicAuth))
authStr := strings.Split(authHeader, " ")
if strings.TrimSpace(authStr[1]) != userAuth {
log.Noticeln("Auth Failed! Get Path is", r.URL.Path, r.RemoteAddr, "pwd enter is", authHeader)
@ -126,14 +87,20 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
}
p := r.URL.Path
cmd := r.URL.Query()["cmd"]
fullpath, _ := filepath.Abs(v.path + p)
if p == "/" && v.indexFile != "" {
tmppath, _ := filepath.Abs(v.path + "/" + v.indexFile)
if staros.Exists(tmppath) {
fullpath = tmppath
p = "/" + v.indexFile
}
}
log.Noticeln("Get " + p + " " + r.RemoteAddr)
fullpath, _ := filepath.Abs(path + p)
if p == "/" {
ReadFolder(w, r, fullpath, true)
v.readFolder(w, r, fullpath, true)
return
}
if up {
if v.upload {
if p == "/vtqeupload1127/web" {
w.Write([]byte(`<html><body><form id= "uploadForm" action= "../vtqeupload1127" method= "post" enctype ="multipart/form-data">
<h1 >B612 File Upload Page </h1>
@ -144,7 +111,7 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
return
}
}
if !starainrt.Exists(fullpath) {
if !staros.Exists(fullpath) {
w.WriteHeader(404)
if len(cmd) != 0 {
if cmd[0] == "header" {
@ -158,8 +125,8 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("<h1>404 NOT FOUND</h1>"))
return
}
if starainrt.IsFolder(fullpath) {
ReadFolder(w, r, fullpath, false)
if staros.IsFolder(fullpath) {
v.readFolder(w, r, fullpath, false)
return
}
fpdst, err := os.Open(fullpath)
@ -171,26 +138,16 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
}
fpinfo, _ := os.Stat(fullpath)
name := filepath.Base(fullpath)
tmp := strings.Split(name, ".")
ext := ""
if len(tmp) >= 2 {
ext = strings.ToLower(tmp[len(tmp)-1])
}
switch ext {
case "jpeg", "jpg", "jpe":
w.Header().Set("Content-Type", "image/jpeg")
case "mpeg", "mpg", "mkv":
w.Header().Set("Content-Type", "video/mpeg")
case "mp4":
w.Header().Set("Content-Type", "video/mp4")
case "pdf":
w.Header().Set("Content-Type", "application/pdf")
default:
ext := filepath.Ext(name)
mime := GetMIME(ext)
if mime == "" || v.stopMime {
w.Header().Set("Content-Type", "application/download")
w.Header().Set("Content-Disposition", "attachment;filename="+name)
w.Header().Set("Content-Transfer-Encoding", "binary")
} else {
w.Header().Set("Content-Type", mime)
}
etag := new(starainrt.StarCrypto).MD5([]byte(fpinfo.ModTime().String()))
w.Header().Set("Content-Transfer-Encoding", "binary")
etag := starcrypto.Md5Str([]byte(fpinfo.ModTime().String()))
w.Header().Set("Accept-Ranges", "bytes")
w.Header().Set("ETag", etag)
w.Header().Set("Last-Modified", strings.ReplaceAll(fpinfo.ModTime().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST"), "UTC", "GMT"))
@ -297,15 +254,15 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
log.Infoln(fpinfo.Name(), "客户端下载已结束,共传输大小:"+tani)
}
func ReadFolder(w http.ResponseWriter, r *http.Request, fullpath string, isroot bool) {
func (v VtqeHttpServer) readFolder(w http.ResponseWriter, r *http.Request, fullpath string, isroot bool) {
dir, err := ioutil.ReadDir(fullpath)
if err != nil {
starlog.Errorln(err)
w.WriteHeader(403)
w.Write([]byte("<h1>May Cannot Access!</h1>"))
}
w.Write([]byte("<html>\n<style>\np{margin: 2px auto}\n</style>\n<h1>B612 Http Server - " + Version + "</h1>"))
if up {
w.Write([]byte("<html>\n<style>\np{margin: 2px auto}\n</style>\n<h1>B612 Http Server - " + v.version + "</h1>"))
if v.upload {
w.Write([]byte("<a href=/vtqeupload1127/web>Upload Web Page Is Openned!</a><br /><br />"))
}
w.Write([]byte("<hr /><pre>\n"))
@ -329,3 +286,29 @@ func ReadFolder(w http.ResponseWriter, r *http.Request, fullpath string, isroot
w.Write([]byte("</pre>\n</html>"))
return
}
func (v VtqeHttpServer) uploadFile(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.Write([]byte("USE POST METHOD!"))
return
}
r.ParseMultipartForm(10485760)
file, handler, err := r.FormFile("victorique")
if err != nil {
starlog.Errorln(err)
w.WriteHeader(502)
w.Write([]byte(err.Error()))
return
}
defer file.Close()
starlog.Noticef("Upload %s From %s\n", handler.Filename, r.RemoteAddr)
fmt.Fprintf(w, `<html><body><p>%v</p><h2><a href="./vtqeupload1127/web">Return To Web Page</a></h2></body></html>`, handler.Header)
os.Mkdir("./vtqeupload1127", 0755)
f, err := os.OpenFile("./vtqeupload1127/"+handler.Filename, os.O_WRONLY|os.O_CREATE, 0755)
if err != nil {
starlog.Errorln(err)
return
}
defer f.Close()
io.Copy(f, file)
}

File diff suppressed because it is too large Load Diff

@ -1,4 +1,4 @@
package tools
package main
import (
"errors"

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -10,7 +10,6 @@ import (
func init() {
imageCmd.AddCommand(imgMirrorCmd)
Maincmd.AddCommand(imageCmd)
}
var imageCmd = &cobra.Command{

@ -0,0 +1,26 @@
package main
import (
"fmt"
"github.com/spf13/cobra"
)
// Vtqe is my own toolbox
func init() {
cmdMain.AddCommand(tcpingcmd, httpcmd, attachcmd, detachcmd, b64cmd, ftpcmd, gencmd, hashcmd, imageCmd, mergecmd, netcmd, sftpcmd, splitcmd, tcpcmd, udpcmd, viccmd, curlcmd)
}
const vtqe_version string = "v1.0.0rc1"
var cmdMain = &cobra.Command{
Short: "Victorique's Wisdom ToolBox",
Long: fmt.Sprintf(`Victorique's Wisdom ToolBox @%v
@B612.ME`, vtqe_version),
Version: vtqe_version,
}
func main() {
cmdMain.Execute()
}

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -44,5 +44,4 @@ var mergecmd = &cobra.Command{
func init() {
mergecmd.Flags().StringP("src", "s", "", "源文件地址,用*替换文件数字")
mergecmd.Flags().StringP("dst", "d", "", "目标文件地址")
Maincmd.AddCommand(mergecmd)
}

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -12,7 +12,6 @@ import (
)
func init() {
Maincmd.AddCommand(netcmd)
netcmd.AddCommand(netforwardcmd, natscmd, natccmd)
netforwardcmd.Flags().BoolP("tcp", "t", false, "TCP转发")
netforwardcmd.Flags().BoolP("udp", "u", false, "UDP转发")

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -161,7 +161,6 @@ var sftpcmd = &cobra.Command{
}
func init() {
Maincmd.AddCommand(sftpcmd)
sftpcmd.Flags().BoolP("download", "D", false, "进行下载")
sftpcmd.Flags().StringP("identify", "i", "", "RSA登录密钥")
sftpcmd.Flags().StringP("password", "k", "", "登录密码")

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -57,5 +57,4 @@ func init() {
splitcmd.Flags().StringP("dst", "d", "./split*.vicque", "目标文件地址,用*替换文件数字")
splitcmd.Flags().BoolP("byte", "b", false, "按byte分割")
splitcmd.Flags().IntP("num", "n", 0, "分割数/byte数")
Maincmd.AddCommand(splitcmd)
}

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -139,7 +139,6 @@ var tcpcmd = &cobra.Command{
*/
func init() {
Maincmd.AddCommand(tcpcmd)
tcpcmd.Flags().BoolP("byte", "b", false, "发送二进制数据")
tcpcmd.Flags().StringP("port", "p", "1127", "本地监听端口")
tcpcmd.Flags().StringP("addr", "a", "0.0.0.0", "本地监听ip")

@ -1,16 +1,14 @@
package tools
package main
import (
"fmt"
"os"
"os/signal"
"strconv"
"syscall"
"tcping/ping"
"time"
"strconv"
"victorique/vtqe/tools/ping"
"github.com/spf13/cobra"
)
@ -32,8 +30,8 @@ var (
var tcpingcmd = &cobra.Command{
Use: "tcping",
Short: "tcp ping",
Long: "进行Tcping",
Short: "tcp/http ping",
Long: "使用进行Tcp或Http协议进行ping探测",
Example: `
1. ping over tcp
> tcping google.com
@ -176,7 +174,3 @@ func init() {
tcpingcmd.Flags().StringArrayVarP(&dnsServer, "dns-server", "D", nil, `使用自定义DNS服务器`)
}
func init() {
Maincmd.AddCommand(tcpingcmd)
}

@ -1,46 +0,0 @@
package tools
import (
"fmt"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var attachcmd = &cobra.Command{
Use: "attach",
Short: "合并两个文件",
Long: "合并两个文件",
Run: func(this *cobra.Command, args []string) {
var src, dst, out string
if len(args) == 3 {
src = args[0]
dst = args[1]
out = args[2]
} else {
src, _ = this.Flags().GetString("src")
dst, _ = this.Flags().GetString("dst")
out, _ = this.Flags().GetString("out")
}
if src == "" || dst == "" {
starlog.Criticalln("ERROR PATH")
this.Help()
return
}
cryp := new(starainrt.StarCrypto)
err := cryp.Attach(src, dst, out)
if err != nil {
starlog.Criticalln(err.Error)
} else {
fmt.Println("完成")
}
},
}
func init() {
attachcmd.Flags().StringP("src", "s", "", "源文件路径")
attachcmd.Flags().StringP("dst", "d", "", "目标文件路径")
attachcmd.Flags().StringP("out", "o", "", "输出文件路径")
Maincmd.AddCommand(attachcmd)
}

@ -1,47 +0,0 @@
// +build windows
package tools
import (
"bufio"
"fmt"
"os"
"os/exec"
"path/filepath"
"b612.me/starainrt"
"github.com/spf13/cobra"
)
var cdcmd = &cobra.Command{
Use: "cd",
Short: "便捷进入文件夹",
Long: "使用stdin便捷进入文件夹",
Run: func(this *cobra.Command, args []string) {
fileInfo, _ := os.Stdin.Stat()
if (fileInfo.Mode() & os.ModeNamedPipe) != os.ModeNamedPipe {
fmt.Println(args)
if len(args) != 0 {
os.Exit(1)
} else {
exec.Command("cmd.exe", "/c", "explorer "+filepath.Dir(args[0])).Run()
return
}
}
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
dir := s.Text()
if starainrt.IsFile(dir) {
exec.Command("cmd.exe", "/c", "explorer /n,/select,"+dir).Run()
} else {
exec.Command("cmd.exe", "/c", "explorer "+dir).Run()
}
return
}
},
}
func init() {
Maincmd.AddCommand(cdcmd)
}

@ -1,19 +0,0 @@
package tools
import (
"github.com/spf13/cobra"
)
var Version string = "0.1.25"
var Maincmd = &cobra.Command{
Use: "",
Short: "Victorique's Small Smart Toolkit",
Long: "Victorique's Small Smart Toolkit",
}
func init() {
cobra.MousetrapHelpText = ""
Maincmd.Flags().BoolP("version", "v", false, "查看版本号")
Maincmd.Version = Version
}

@ -1,6 +1,6 @@
// +build windows
package tools
package main
import (
"os"
@ -29,5 +29,5 @@ var uaccmd = &cobra.Command{
}
func init() {
Maincmd.AddCommand(uaccmd)
cmdMain.AddCommand(uaccmd)
}

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -118,7 +118,6 @@ var udpcmd = &cobra.Command{
*/
func init() {
Maincmd.AddCommand(udpcmd)
udpcmd.Flags().BoolP("byte", "b", false, "发送二进制数据")
udpcmd.Flags().StringP("port", "p", "1127", "本地监听端口")
udpcmd.Flags().StringP("addr", "a", "0.0.0.0", "本地监听ip")

@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@ -13,7 +13,7 @@ import (
var viccmd = &cobra.Command{
Use: "vicque",
Short: "嵐を乗り越えて",
Long: "ほら!嵐を乗り越えて",
Long: "あの子の未来を照らし出せ",
Run: func(this *cobra.Command, args []string) {
var err error
ok, _ := this.Flags().GetBool("file")
@ -91,5 +91,4 @@ func init() {
viccmd.Flags().BoolP("replace", "r", false, "覆盖原文件")
viccmd.Flags().BoolP("extension", "e", false, "添加/取消.victorique后缀")
viccmd.MarkFlagRequired("key")
Maincmd.AddCommand(viccmd)
}
Loading…
Cancel
Save