6 Commits

Author SHA1 Message Date
b612 382badb0cc fix mime bug which will make server not recognize filename without dot 2020-08-21 14:16:32 +08:00
b612 9e7ad45f06 v1.0.0rc1 update 2020-08-21 10:48:02 +08:00
b612 4a8458fab6 save 2020-08-13 17:40:54 +08:00
b612 7835d1fae7 save 2020-08-13 14:33:05 +08:00
b612 f89188761d new gen 2020-08-13 14:02:33 +08:00
b612 f8bcc2c171 version 0.1.25 2020-08-13 13:45:27 +08:00
36 changed files with 2756 additions and 455 deletions
+1
View File
@@ -0,0 +1 @@
package main
+90
View File
@@ -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
}
+14
View File
@@ -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"))
}
+78
View File
@@ -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", "", "输出文件路径")
}
+8 -10
View File
@@ -1,9 +1,9 @@
package tools
package main
import (
"fmt"
"b612.me/starainrt"
"b612.me/starcrypto"
"b612.me/starlog"
"github.com/spf13/cobra"
)
@@ -17,7 +17,7 @@ var b64cmd = &cobra.Command{
ok, _ := this.Flags().GetBool("file")
de, _ := this.Flags().GetBool("decode")
if len(args) != 1 {
starlog.StdPrintln(0, starlog.RED, "参数不足,请输入文件地址或字符串")
starlog.Criticalln("参数不足,请输入文件地址或字符串")
this.Help()
return
}
@@ -28,26 +28,25 @@ 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))
}
}
if err != nil {
starlog.StdPrintln(0, starlog.RED, err)
starlog.Criticalln(err)
return
}
},
@@ -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)
}
-9
View File
@@ -1,9 +0,0 @@
package main
import (
"Victorique/vtqe/tools"
)
func main() {
tools.Maincmd.Execute()
}
+1 -2
View File
@@ -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", "", "上传文件的地址")
+3 -4
View File
@@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@@ -25,14 +25,14 @@ var detachcmd = &cobra.Command{
}
num, _ := this.Flags().GetInt("num")
if src == "" || dst == "" {
starlog.StdPrintln(0, starlog.RED, "ERROR PATH")
starlog.Criticalln("ERROR PATH")
this.Help()
return
}
cryp := new(starainrt.StarCrypto)
err := cryp.Detach(src, num, dst, out)
if err != nil {
starlog.StdPrintln(0, starlog.RED, err.Error)
starlog.Criticalln(err.Error)
} else {
fmt.Println("完成")
}
@@ -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)
}
+2 -2
View File
@@ -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")
+20 -7
View File
@@ -1,7 +1,9 @@
package tools
package main
import (
"fmt"
"os"
"time"
"b612.me/starainrt"
"github.com/spf13/cobra"
@@ -14,26 +16,37 @@ var gencmd = &cobra.Command{
Run: func(this *cobra.Command, args []string) {
sum, _ := this.Flags().GetInt("sum")
num, _ := this.Flags().GetInt("num")
cap, _ := this.Flags().GetInt("cap")
if len(args) != 1 {
this.Help()
return
}
err := starainrt.FillWithRandom(args[0], num, 1024*1024, sum, func(pect float64) {
if pect == 100 {
fmt.Println("文件已处理:100.000000%")
} else {
fmt.Printf("文件已处理:%f%%\r", pect)
if num <= 0 {
fmt.Println("num不合法,不应该小于1")
os.Exit(2)
}
if sum <= 0 {
fmt.Println("sum不合法,不应该小于1")
os.Exit(2)
}
if cap <= 0 {
fmt.Println("cap不合法,不应该小于1")
os.Exit(2)
}
err := starainrt.FillWithRandom(args[0], num, cap, sum, func(pect float64) {
fmt.Printf("文件已处理:%f%%\r", pect)
})
if err != nil {
fmt.Println("err:" + err.Error())
}
fmt.Println("文件已处理:100.0000000%")
time.Sleep(time.Millisecond * 10)
},
}
func init() {
gencmd.Flags().IntP("sum", "s", 3, "随机的种子组数")
gencmd.Flags().IntP("num", "n", 1024, "生成的文件大小")
gencmd.Flags().IntP("cap", "c", 1048576, "bufcap大小")
gencmd.MarkFlagRequired("num")
Maincmd.AddCommand(gencmd)
}
+2 -3
View File
@@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@@ -49,7 +49,7 @@ var hashcmd = &cobra.Command{
result, err = crypto.SumAll([]byte(args[0]), method)
}
if err != nil {
starlog.StdPrintln(0, starlog.RED, "错误:"+err.Error())
starlog.Criticalln("错误:" + err.Error())
}
for _, v := range method {
fmt.Printf("%s%s\n", v, result[v])
@@ -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)
}
+93
View File
@@ -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
}
}
+147 -94
View File
@@ -1,6 +1,8 @@
package tools
package httpserver
import (
"encoding/base64"
"errors"
"fmt"
"io"
"io/ioutil"
@@ -10,79 +12,95 @@ 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
type TraceHandler struct {
h http.Handler
type VtqeHttpServer struct {
basicAuth string
path string
upload bool
version string
indexFile string
stopMime bool
}
// httpCmd represents the http command
var httpcmd = &cobra.Command{
Use: "http",
Short: "HTTP文件服务器",
Long: `HTTP文件服务器`,
Run: func(cmd *cobra.Command, args []string) {
http.HandleFunc("/", httplisten)
path, _ = filepath.Abs(path)
fmt.Println("Listening On Port:" + port)
if up {
fmt.Println("upload is openned,path is /vtqeupload1127")
http.HandleFunc("/vtqeupload1127", uploadfile)
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)
}
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)
}
err := http.ListenAndServe(ip+":"+port, nil)
if err != nil {
starlog.StdPrintln(0, starlog.RED, "Error:"+err.Error())
starlog.Criticalln("Error:" + err.Error())
return err
}
},
return nil
}
func 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 {
fmt.Println(err)
w.WriteHeader(502)
w.Write([]byte(err.Error()))
return
}
defer file.Close()
fmt.Printf("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 {
fmt.Println(err)
return
}
defer f.Close()
io.Copy(f, file)
}
func httplisten(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "Vicorique")
func (v VtqeHttpServer) httpListen(w http.ResponseWriter, r *http.Request) {
log := starlog.Std.NewFlag()
w.Header().Set("Server", "Victorique")
w.Header().Set("Powered", "B612.ME")
write401 := func() {
w.Header().Set("WWW-Authenticate", ` Basic realm="Please Enter Passwd"`)
w.WriteHeader(401)
w.Write([]byte(`
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>B612 HTTP SERVER</center>
</body>
</html>`))
}
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(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)
write401()
return
}
}
}
p := r.URL.Path
cmd := r.URL.Query()["cmd"]
fmt.Println("Get " + p + " " + r.RemoteAddr)
fullpath, _ := filepath.Abs(path + p)
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)
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>
@@ -93,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" {
@@ -107,42 +125,32 @@ 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)
if err != nil {
fmt.Println(err)
log.Errorln(err)
w.WriteHeader(403)
w.Write([]byte("<h1>403 NO ACCESS</h1>"))
return
}
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)
}
etag := new(starainrt.StarCrypto).MD5([]byte(fpinfo.ModTime().String()))
w.Header().Set("Content-Transfer-Encoding", "binary")
} else {
w.Header().Set("Content-Type", mime)
}
etag := starcrypto.Md5Str([]byte(fpinfo.ModTime().String()))
w.Header().Set("Accept-Ranges", "bytes")
w.Header().Set("ETag", etag)
w.Header().Set("Last-Modified", fpinfo.ModTime().Format("Mon,2 Jan 2006 15:04:05 MST"))
w.Header().Set("Last-Modified", strings.ReplaceAll(fpinfo.ModTime().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST"), "UTC", "GMT"))
isRange := false
var rangeStart, rangeEnd int64
rangeEnd = -1
@@ -166,19 +174,26 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
}
}
defer fpdst.Close()
var transferData int
if !isRange {
w.Header().Set("Content-Length", strconv.FormatInt(fpinfo.Size(), 10))
w.WriteHeader(200)
for {
buf := make([]byte, 1048576)
n, err := fpdst.Read(buf)
if n != 0 {
ns, err := w.Write(buf[0:n])
transferData += ns
if err != nil {
starlog.Errorln("Transfer Error:", err)
}
}
if err != nil {
if err == io.EOF {
break
}
return
break
}
w.Write(buf[0:n])
}
} else {
w.Header().Set("Content-Length", strconv.FormatInt(fpinfo.Size(), 10))
@@ -202,7 +217,11 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
return
}
if rangeEnd == -1 {
w.Write(buf[0:n])
ns, err := w.Write(buf[0:n])
transferData += ns
if err != nil {
starlog.Errorln("Transfer Error:", err)
}
} else {
if count > rangeEnd {
break
@@ -211,24 +230,39 @@ func httplisten(w http.ResponseWriter, r *http.Request) {
w.Write(buf[0 : rangeEnd-count+1])
break
} else {
w.Write(buf[0:n])
ns, err := w.Write(buf[0:n])
transferData += ns
if err != nil {
starlog.Errorln("Transfer Error:", err)
}
count += int64(n)
}
}
}
fmt.Println(fpinfo.Name(), "客户端下载已结束")
}
var tani string
tani = fmt.Sprintf("%v Byte", transferData)
if f64 := float64(transferData) / 1024; f64 > 1 {
tani = fmt.Sprintf("%v KB", f64)
if f64 = float64(f64) / 1024; f64 > 1 {
tani = fmt.Sprintf("%v MB", f64)
if f64 = float64(f64) / 1024; f64 > 1 {
tani = fmt.Sprintf("%v GB", f64)
}
}
}
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 {
fmt.Println(err)
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"))
@@ -252,10 +286,29 @@ func ReadFolder(w http.ResponseWriter, r *http.Request, fullpath string, isroot
w.Write([]byte("</pre>\n</html>"))
return
}
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, "是否开启文件上传")
Maincmd.AddCommand(httpcmd)
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"
+7 -8
View File
@@ -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{
@@ -28,13 +27,13 @@ var imgMirrorCmd = &cobra.Command{
Long: "图像镜像翻转<水平>",
Run: func(this *cobra.Command, args []string) {
if len(args) == 0 {
starlog.StdPrintln(0, starlog.RED, "请指定需要转换的图像!")
starlog.Errorln("请指定需要转换的图像!")
return
}
for _, v := range args {
img, err := OpenImage(v)
if err != nil {
starlog.StdPrintln(0, starlog.RED, err, v)
starlog.Errorln(err, v)
continue
}
size := img.Bounds()
@@ -45,7 +44,7 @@ var imgMirrorCmd = &cobra.Command{
}
}
if err := SavePhoto(v, nimg); err != nil {
starlog.StdPrintln(0, starlog.RED, err, v)
starlog.Errorln(err, v)
continue
} else {
fmt.Println(v, "转换已完成!")
@@ -61,18 +60,18 @@ var imgAlpha = &cobra.Command{
Long: "设置alpha通道透明度",
Run: func(this *cobra.Command, args []string) {
if len(args) == 0 {
starlog.StdPrintln(0, starlog.RED, "请指定需要转换的图像!")
starlog.Errorln("请指定需要转换的图像!")
return
}
for _, v := range args {
img, err := OpenImage(v)
if err != nil {
starlog.StdPrintln(0, starlog.RED, err, v)
starlog.Errorln(err, v)
continue
}
img = SetAlpha(img, 4)
if err := SavePhoto(v, img); err != nil {
starlog.StdPrintln(0, starlog.RED, err, v)
starlog.Errorln(err, v)
continue
} else {
fmt.Println(v, "转换已完成!")
+26
View File
@@ -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()
}
+2 -3
View File
@@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@@ -35,7 +35,7 @@ var mergecmd = &cobra.Command{
}
})
if err != nil {
starlog.StdPrintln(0, starlog.RED, err.Error)
starlog.Errorln(err.Error)
}
},
@@ -44,5 +44,4 @@ var mergecmd = &cobra.Command{
func init() {
mergecmd.Flags().StringP("src", "s", "", "源文件地址,用*替换文件数字")
mergecmd.Flags().StringP("dst", "d", "", "目标文件地址")
Maincmd.AddCommand(mergecmd)
}
+15 -8
View File
@@ -1,17 +1,17 @@
package tools
package main
import (
"fmt"
"io"
"net"
"strconv"
"strings"
"time"
"github.com/spf13/cobra"
)
func init() {
Maincmd.AddCommand(netcmd)
netcmd.AddCommand(netforwardcmd, natscmd, natccmd)
netforwardcmd.Flags().BoolP("tcp", "t", false, "TCP转发")
netforwardcmd.Flags().BoolP("udp", "u", false, "UDP转发")
@@ -668,21 +668,23 @@ func TcpNatServer(tcplocal *net.TCPAddr, pwd string) {
}()
}
return
}
}()
go func() {
if isconn {
} else {
isRun := false
buf := make([]byte, 7)
if strings.Split(conn.RemoteAddr().String(), ":")[0] == strings.Split(trueconn.RemoteAddr().String(), ":")[0] {
isRun = true
n, err := conn.Read(buf)
if n != 7 || err != nil {
conn.Close()
return
}
}
if string(buf) == "v%2^f&K" {
fmt.Println("穿透客户端已建立新连接")
if len(waitconn) != 0 {
if waitconn[0].Msg != nil {
conn.Write(waitconn[0].Msg)
}
waitconn[0].Msg = []byte{}
go TcpCopy(waitconn[0].Conn, conn)
go TcpCopy(conn, waitconn[0].Conn)
@@ -696,7 +698,12 @@ func TcpNatServer(tcplocal *net.TCPAddr, pwd string) {
}
} else {
fmt.Println("链接已加入等待列表")
tcpnats := tcpnat{Msg: buf, Conn: conn, Date: time.Now().Unix()}
var tcpnats tcpnat
if isRun {
tcpnats = tcpnat{Msg: buf, Conn: conn, Date: time.Now().Unix()}
} else {
tcpnats = tcpnat{Msg: nil, Conn: conn, Date: time.Now().Unix()}
}
waitconn = append(waitconn, tcpnats)
if trueconn == nil {
isconn = false
+1 -2
View File
@@ -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", "", "登录密码")
+4 -5
View File
@@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@@ -27,12 +27,12 @@ var splitcmd = &cobra.Command{
num, _ = this.Flags().GetInt("num")
}
if !starainrt.Exists(src) {
starlog.StdPrintln(0, starlog.RED, "源文件不存在")
starlog.Errorln("源文件不存在")
this.Help()
return
}
if num == 0 {
starlog.StdPrintln(0, starlog.RED, "参数num不合法", "red")
starlog.Errorln("参数num不合法", "red")
this.Help()
return
}
@@ -46,7 +46,7 @@ var splitcmd = &cobra.Command{
}
})
if err != nil {
starlog.StdPrintln(0, starlog.RED, err.Error)
starlog.Errorln(err.Error)
}
},
@@ -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)
}
+19 -11
View File
@@ -1,4 +1,4 @@
package tools
package main
import (
"fmt"
@@ -14,6 +14,7 @@ import (
"time"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
@@ -23,7 +24,8 @@ var tcpcmd = &cobra.Command{
Short: "发送并监听tcp数据包",
Long: "发送并监听tcp数据包",
Run: func(this *cobra.Command, args []string) {
if len(args) != 1 {
r, _ := this.Flags().GetBool("recvonly")
if len(args) != 1 && !r {
fmt.Println("请指定远程tcp地址")
return
}
@@ -51,19 +53,19 @@ var tcpcmd = &cobra.Command{
fmt.Printf("Error Connect From %s : %s\n", conn.RemoteAddr(), err.Error())
continue
}
fmt.Printf("Accept Connect From %s\n", conn.RemoteAddr())
starlog.Infof("Accept Connect From %s\n", conn.RemoteAddr())
go func(conns *net.TCPConn) {
for {
buf := make([]byte, 204800)
n, err := conns.Read(buf)
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", conns.RemoteAddr(), err.Error())
starlog.Infof("Error from %s Where Message=%s\n", conns.RemoteAddr(), err.Error())
conn.Close()
return
}
fmt.Printf("Receive Msg From %s : %s\n", conns.RemoteAddr(), string(buf[0:n]))
starlog.Infof("Receive Msg From %s : %s\n", conns.RemoteAddr(), string(buf[0:n]))
if b {
fmt.Println(buf[0:n])
starlog.Infof("%#v", buf[0:n])
}
}
@@ -71,6 +73,7 @@ var tcpcmd = &cobra.Command{
}
}()
}
if !r {
mytcp, err := net.DialTimeout("tcp", args[0], time.Second*15)
if err != nil {
fmt.Println(err)
@@ -105,7 +108,7 @@ var tcpcmd = &cobra.Command{
_, err = mytcp.Write(sendbyte)
}
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", mytcp.RemoteAddr().String(), err.Error())
starlog.Errorf("Error from %s Where Message=%s\n", mytcp.RemoteAddr().String(), err.Error())
return
}
}
@@ -114,13 +117,18 @@ var tcpcmd = &cobra.Command{
buf := make([]byte, 204800)
n, err := mytcp.Read(buf)
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", mytcp.RemoteAddr().String(), err.Error())
starlog.Errorf("Error from %s Where Message=%s\n", mytcp.RemoteAddr().String(), err.Error())
return
}
fmt.Printf("Receive Msg From %s : %s\n", mytcp.RemoteAddr().String(), string(buf[0:n]))
starlog.Infof("Receive Msg From %s : %s\n", mytcp.RemoteAddr().String(), string(buf[0:n]))
if b {
fmt.Println(buf[0:n])
starlog.Infof("%#v", buf[0:n])
}
}
} else {
for {
time.Sleep(time.Second)
}
}
},
@@ -131,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")
@@ -141,6 +148,7 @@ func init() {
tcpsendcmd.Flags().StringP("regexp", "r", "", "正则匹配字符串")
tcprecvcmd.Flags().StringP("port", "p", "1127", "本地监听端口")
tcprecvcmd.Flags().StringP("addr", "a", "0.0.0.0", "本地监听ip")
tcpcmd.Flags().BoolP("recvonly", "r", false, "仅接收udp包")
tcpcmd.AddCommand(tcpsendcmd, tcprecvcmd)
}
+6 -12
View File
@@ -1,15 +1,13 @@
package tools
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
"strconv"
"victorique/vtqe/tools/ping"
"syscall"
"tcping/ping"
"time"
"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)
}
-46
View File
@@ -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.StdPrintln(0, starlog.RED, "ERROR PATH")
this.Help()
return
}
cryp := new(starainrt.StarCrypto)
err := cryp.Attach(src, dst, out)
if err != nil {
starlog.StdPrintln(0, starlog.RED, 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)
}
-38
View File
@@ -1,38 +0,0 @@
// +build windows
package tools
import (
"bufio"
"os"
"os/exec"
"path/filepath"
"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 {
if len(args) != 1 {
os.Exit(1)
} else {
exec.Command("cmd.exe", "/c", "explorer "+filepath.Dir(args[0])).Run()
return
}
}
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
exec.Command("cmd.exe", "/c", "explorer "+filepath.Dir(s.Text())).Run()
return
}
},
}
func init() {
Maincmd.AddCommand(cdcmd)
}
-19
View File
@@ -1,19 +0,0 @@
package tools
import (
"github.com/spf13/cobra"
)
var Version string = "0.1.24"
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
}
-114
View File
@@ -1,114 +0,0 @@
package tools
import (
"fmt"
"net"
"strconv"
"strings"
"b612.me/starainrt"
"github.com/spf13/cobra"
)
var udpcmd = &cobra.Command{
Use: "udp",
Short: "发送并监听udp数据包",
Long: "发送并监听udp数据包",
Run: func(this *cobra.Command, args []string) {
if len(args) != 1 {
fmt.Println("请指定远程udp地址")
return
}
l, _ := this.Flags().GetString("port")
a, _ := this.Flags().GetString("addr")
s, _ := this.Flags().GetBool("local")
b, _ := this.Flags().GetBool("byte")
laddr, err := net.ResolveUDPAddr("udp", a+":"+l)
raddr, err := net.ResolveUDPAddr("udp", args[0])
if err != nil {
fmt.Println(err)
return
}
if s {
udplisten, err := net.ListenUDP("udp", laddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("监听已建立")
go func() {
for {
buf := make([]byte, 204800)
n, addr, err := udplisten.ReadFromUDP(buf)
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", addr.String(), err.Error())
continue
}
fmt.Printf("Receive Msg From %s : %s\n", addr.String(), string(buf[0:n]))
if b {
fmt.Println(buf[0:n])
}
}
}()
}
myudp, err := net.DialUDP("udp", nil, raddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("UDP虚拟连接已建立")
go func() {
var err error
for {
txt := starainrt.MessageBox("", "")
if txt == "" {
continue
}
if !b {
_, err = myudp.Write([]byte(txt))
} else {
var sendbyte []byte
bytes := strings.Split(txt, ",")
for _, v := range bytes {
ints, _ := strconv.Atoi(v)
if ints < 0 || ints > 255 {
continue
}
sendbyte = append(sendbyte, byte(ints))
}
_, err = myudp.Write(sendbyte)
}
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", myudp.RemoteAddr().String(), err.Error())
return
}
}
}()
for {
buf := make([]byte, 204800)
n, err := myudp.Read(buf)
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", myudp.RemoteAddr().String(), err.Error())
return
}
fmt.Printf("Receive Msg From %s : %s\n", myudp.RemoteAddr().String(), string(buf[0:n]))
if b {
fmt.Println(buf[0:n])
}
}
},
}
/*
*/
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")
udpcmd.Flags().BoolP("local", "s", false, "启动本地监听")
}
+2 -2
View File
@@ -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)
}
+126
View File
@@ -0,0 +1,126 @@
package main
import (
"fmt"
"net"
"strconv"
"strings"
"time"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var udpcmd = &cobra.Command{
Use: "udp",
Short: "发送并监听udp数据包",
Long: "发送并监听udp数据包",
Run: func(this *cobra.Command, args []string) {
var raddr *net.UDPAddr
r, _ := this.Flags().GetBool("recvonly")
if len(args) != 1 && !r {
fmt.Println("请指定远程udp地址")
return
}
l, _ := this.Flags().GetString("port")
a, _ := this.Flags().GetString("addr")
s, _ := this.Flags().GetBool("local")
b, _ := this.Flags().GetBool("byte")
laddr, err := net.ResolveUDPAddr("udp", a+":"+l)
if !r {
raddr, err = net.ResolveUDPAddr("udp", args[0])
}
if err != nil {
fmt.Println(err)
return
}
if s {
udplisten, err := net.ListenUDP("udp", laddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("监听已建立")
go func() {
for {
buf := make([]byte, 204800)
n, addr, err := udplisten.ReadFromUDP(buf)
if err != nil {
starlog.Errorln("Error from %s Where Message=%s\n", addr.String(), err.Error())
continue
}
starlog.Infof("Receive Msg From %s : %s\n", addr.String(), string(buf[0:n]))
if b {
starlog.Infof("%#v\n", buf[0:n])
}
}
}()
}
if !r {
myudp, err := net.DialUDP("udp", nil, raddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("UDP虚拟连接已建立")
go func() {
var err error
for {
txt := starainrt.MessageBox("", "")
if txt == "" {
continue
}
if !b {
_, err = myudp.Write([]byte(txt))
} else {
var sendbyte []byte
bytes := strings.Split(txt, ",")
for _, v := range bytes {
ints, _ := strconv.Atoi(v)
if ints < 0 || ints > 255 {
continue
}
sendbyte = append(sendbyte, byte(ints))
}
_, err = myudp.Write(sendbyte)
}
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", myudp.RemoteAddr().String(), err.Error())
return
}
}
}()
for {
buf := make([]byte, 204800)
n, err := myudp.Read(buf)
if err != nil {
starlog.Infof("Error from %s Where Message=%s\n", myudp.RemoteAddr().String(), err.Error())
return
}
starlog.Infof("Receive Msg From %s : %s\n", myudp.RemoteAddr().String(), string(buf[0:n]))
if b {
starlog.Infof("%#v", buf[0:n])
}
}
} else {
for {
time.Sleep(time.Second)
}
}
},
}
/*
*/
func init() {
udpcmd.Flags().BoolP("byte", "b", false, "发送二进制数据")
udpcmd.Flags().StringP("port", "p", "1127", "本地监听端口")
udpcmd.Flags().StringP("addr", "a", "0.0.0.0", "本地监听ip")
udpcmd.Flags().BoolP("local", "s", false, "启动本地监听")
udpcmd.Flags().BoolP("recvonly", "r", false, "仅接收udp包")
}
+4 -5
View File
@@ -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")
@@ -22,7 +22,7 @@ var viccmd = &cobra.Command{
rep, _ := this.Flags().GetBool("replace")
ext, _ := this.Flags().GetBool("extension")
if len(args) != 2 || args[1] != "sakura" {
starlog.StdPrintln(0, starlog.RED, "ヴィクトリカだけが使えるよ")
starlog.Errorln("ヴィクトリカだけが使えるよ")
return
}
shell := func(pect float64) {
@@ -77,7 +77,7 @@ var viccmd = &cobra.Command{
}
}
if err != nil {
starlog.StdPrintln(0, starlog.RED, err)
starlog.Errorln(err)
return
}
},
@@ -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)
}