├── .github └── workflows │ └── release.yml ├── .gitignore ├── .goreleaser.yml ├── LICENSE ├── README.md ├── cmd ├── convert.go ├── decrypt.go ├── deserialize.go ├── items.go ├── list.go ├── root.go └── serialize.go ├── go.mod ├── go.sum ├── internal ├── assets │ ├── asset.go │ ├── balance_to_inv_key.go │ └── inventory_raw.go └── server │ ├── backup.go │ ├── character.go │ ├── convert.go │ ├── convert_test.go │ ├── crossplatform.go │ ├── options.go │ ├── profile.go │ └── server.go └── main.go /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: goreleaser 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*.*.*' 7 | 8 | jobs: 9 | goreleaser: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - 13 | name: Checkout 14 | uses: actions/checkout@v2 15 | - 16 | name: Unshallow 17 | run: git fetch --prune --unshallow 18 | - 19 | name: Set up Go 20 | uses: actions/setup-go@v1 21 | with: 22 | go-version: 1.14.x 23 | - 24 | name: Run GoReleaser 25 | uses: goreleaser/goreleaser-action@v1 26 | with: 27 | version: latest 28 | args: release --rm-dist 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | **/*.sav 3 | bl3-save 4 | **/pax 5 | 6 | assets/* 7 | **/*.exe 8 | **/*.txt -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # This is an example goreleaser.yaml file with some sane defaults. 2 | # Make sure to check the documentation at http://goreleaser.com 3 | before: 4 | hooks: 5 | # You may remove this if you don't use go modules. 6 | - go mod download 7 | # you may remove this if you don't need go generate 8 | # - go generate ./... 9 | builds: 10 | - env: 11 | - CGO_ENABLED=0 12 | goos: 13 | - darwin 14 | - linux 15 | - windows 16 | goarch: 17 | - amd64 18 | - 386 19 | archives: 20 | - replacements: 21 | darwin: Darwin 22 | linux: Linux 23 | windows: Windows 24 | 386: i386 25 | amd64: x86_64 26 | files: 27 | - LICENSE* 28 | - README* 29 | - CHANGELOG* 30 | format_overrides: 31 | - goos: windows 32 | format: zip 33 | checksum: 34 | name_template: 'checksums.txt' 35 | snapshot: 36 | name_template: "{{ .Tag }}-next" 37 | changelog: 38 | sort: asc 39 | filters: 40 | exclude: 41 | - '^docs:' 42 | - '^test:' 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 cfi2017 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/cfi2017/bl3-save?status.svg)](https://godoc.org/github.com/cfi2017/bl3-save) 2 | [![Go Report Card](https://goreportcard.com/badge/github.com/cfi2017/bl3-save)](https://goreportcard.com/report/github.com/cfi2017/bl3-save) 3 | ![GitHub All Releases](https://img.shields.io/github/downloads/cfi2017/bl3-save/total) 4 | 5 | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I15DZCA) 6 | 7 | # bl3-save 8 | 9 | Command line utility for modifying borderlands 3 character and profile saves. 10 | 11 | ## Getting started 12 | 13 | To get the utility, go to the [releases](https://github.com/cfi2017/bl3-save/releases) page or 14 | run `go get github.com/cfi2017/bl3-save`. 15 | 16 | **If you're using Steam, make sure to disable cloud synchronisation or Steam will overwrite your changes with your cloud 17 | save.** 18 | 19 | **Make sure to make a backup before using this tool. The author takes no responsibility for any loss of progress as a result of this.** 20 | 21 | ## Using 22 | - Extract the files from the release into your Borderlands 3 Save directory. 23 | - Run bl3-save.exe. 24 | 25 | ## Backups 26 | This tool automatically creates backups of your save files whenever you save them. 27 | You can find these backups in the backup directory of your save files. 28 | 29 | ## Credits 30 | 31 | Credits go to these amazing people for all various sorts of reasons: 32 | - Gibbed & Apocalyptech for their work on decrypting and decoding save files and items 33 | - Cu3PO42 for expanding on the roadmap and their input regarding various features of the client. 34 | - aprizm for collaboration for conversion between items in various formats and base64 encoded json 35 | 36 | ### Bug hunters 37 | - Zydiz 38 | 39 | ## Other Tools 40 | 41 | There are a plethora of modding tools out there by now, 42 | here are some select few that drew my attention while working on this project: 43 | - [Apocalyptech's Commandline Editor](https://github.com/apocalyptech/bl3-cli-saveedit) 44 | - [BaySix' Web Based Editor](https://www.bl3editor.com) 45 | - [Digital_Marine's Memory Editor (Links to Discord)](https://discord.gg/38sDVpE) 46 | 47 | ## Tool Comparison Chart 48 | 49 | todo 50 | -------------------------------------------------------------------------------- /cmd/convert.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "encoding/base64" 7 | "encoding/json" 8 | "errors" 9 | "fmt" 10 | "io" 11 | "os" 12 | "strings" 13 | "sync" 14 | "unicode/utf8" 15 | 16 | "github.com/cfi2017/bl3-save-core/pkg/assets" 17 | "github.com/cfi2017/bl3-save-core/pkg/item" 18 | "github.com/spf13/cobra" 19 | ) 20 | 21 | var ( 22 | literals []string 23 | files []string 24 | ) 25 | 26 | // deserializeCmd represents the deserialize command 27 | var ConvertCmd = &cobra.Command{ 28 | Use: "convert", 29 | Short: "Convert an item from gibbed to digital_marine or vice versa", 30 | Args: cobra.MaximumNArgs(2), 31 | Run: func(cmd *cobra.Command, args []string) { 32 | if len(args) > 0 { 33 | if len(args) > 1 { 34 | literals = append(literals, args[0]+" "+args[1]) 35 | } else { 36 | literals = append(literals, args[0]) 37 | } 38 | } 39 | 40 | queue := make(chan string) 41 | done := sync.WaitGroup{} 42 | 43 | done.Add(1) 44 | go func() { 45 | for literal := range queue { 46 | c, err := convert(literal) 47 | if err != nil { 48 | cmd.PrintErr(err) 49 | return 50 | } 51 | cmd.Println(c) 52 | } 53 | done.Done() 54 | }() 55 | 56 | for _, literal := range literals { 57 | queue <- literal 58 | } 59 | 60 | for _, file := range files { 61 | var reader io.Reader 62 | var err error 63 | if file != "-" { 64 | reader, err = os.Open(file) 65 | if err != nil { 66 | cmd.PrintErr(err) 67 | return 68 | } 69 | } else { 70 | reader = os.Stdin 71 | } 72 | scanner := bufio.NewScanner(reader) 73 | for scanner.Scan() { 74 | queue <- scanner.Text() 75 | } 76 | if err := scanner.Err(); err != nil { 77 | cmd.PrintErr(err) 78 | return 79 | } 80 | if f, ok := reader.(*os.File); ok { 81 | err = f.Close() 82 | if err != nil { 83 | cmd.PrintErr(err) 84 | return 85 | } 86 | } 87 | } 88 | close(queue) 89 | done.Wait() 90 | }, 91 | } 92 | 93 | type Anointments struct { 94 | CopyType string `json:"copyType"` 95 | ComponentNames []string `json:"componentNames"` 96 | Components []int `json:"components"` 97 | } 98 | 99 | func convert(arg string) (string, error) { 100 | anoints := make([]string, 0) 101 | arg = strings.TrimSpace(arg) 102 | if parts := strings.Split(arg, " "); len(parts) > 1 { 103 | var anointments Anointments 104 | bs, err := base64.StdEncoding.DecodeString(parts[1]) 105 | if err != nil { 106 | return "", err 107 | } 108 | err = json.Unmarshal(bs, &anointments) 109 | if anointments.CopyType != "anoinment" { 110 | return "", errors.New("not a valid anointment code") 111 | } 112 | for _, i := range anointments.Components { 113 | anoints = append(anoints, item.DmKeyToInvKey(anointments.ComponentNames[i], 114 | assets.GetDB().GetData("InventoryGenericPartData").Assets)) 115 | if strings.Contains(anointments.ComponentNames[i], "WeaponMayhemLevel_11") { 116 | anoints[len(anoints)-1] = "/Game/PatchDLC/Mayhem2/Gear/Weapon/_Shared/_Design/MayhemParts/Part_WeaponMayhemLevel_10.Part_WeaponMayhemLevel_10" 117 | } 118 | } 119 | arg = parts[0] 120 | } 121 | arg = strings.TrimSpace(arg) 122 | arg = strings.TrimPrefix(arg, "bl3(") 123 | arg = strings.TrimPrefix(arg, "BL3(") 124 | arg = strings.TrimSuffix(arg, ")") 125 | arg = string(bytes.TrimPrefix([]byte(arg), []byte{0xEF, 0xBB, 0xBF})) 126 | bs, err := base64.StdEncoding.DecodeString(arg) 127 | if err != nil { 128 | arg = string(StringToAsciiBytes(arg)) 129 | bs, err = base64.StdEncoding.DecodeString(arg) 130 | if err != nil { 131 | panic(err) 132 | } 133 | } 134 | var dmi item.DigitalMarineItem 135 | err = json.Unmarshal(bs, &dmi) 136 | if err != nil { 137 | // try deserializing item 138 | i, err := item.Deserialize(bs) 139 | if err != nil { 140 | return "", errors.New("couldn't deserialize item") 141 | } 142 | // convert to dm item 143 | bs, err = json.Marshal(item.GibbedToDm(i)) 144 | if err != nil { 145 | return "", errors.New("couldn't convert item to dm format") 146 | } 147 | return base64.StdEncoding.EncodeToString(bs), nil 148 | } 149 | i := item.DmToGibbed(dmi) 150 | // we don't check for existing anoints at the moment, 151 | // nor anoint count (todo: add sanity checks) 152 | i.Generics = append(i.Generics, anoints...) 153 | bs, err = item.Serialize(i, 0) // encrypt with 0 seed 154 | if err != nil { 155 | return "", err 156 | } 157 | return fmt.Sprintf("bl3(%s)", base64.StdEncoding.EncodeToString(bs)), nil 158 | } 159 | 160 | func init() { 161 | ConvertCmd.SetOut(os.Stdout) 162 | rootCmd.AddCommand(ConvertCmd) 163 | 164 | ConvertCmd.PersistentFlags().StringSliceVar(&literals, "from-literal", []string{}, "literal code inputs") 165 | ConvertCmd.PersistentFlags().StringSliceVar(&files, "from-file", []string{}, "input files") 166 | // Here you will define your flags and configuration settings. 167 | 168 | // Cobra supports Persistent Flags which will work for this command 169 | // and all subcommands, e.g.: 170 | // deserializeCmd.PersistentFlags().String("foo", "", "A help for foo") 171 | 172 | // Cobra supports local flags which will only run when this command 173 | // is called directly, e.g.: 174 | // deserializeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 175 | } 176 | 177 | func StringToAsciiBytes(s string) []byte { 178 | t := make([]byte, utf8.RuneCountInString(s)) 179 | i := 0 180 | for _, r := range s { 181 | t[i] = byte(r) 182 | i++ 183 | } 184 | return t 185 | } 186 | -------------------------------------------------------------------------------- /cmd/decrypt.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "log" 5 | "os" 6 | 7 | "github.com/cfi2017/bl3-save-core/pkg/character" 8 | "github.com/cfi2017/bl3-save-core/pkg/profile" 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | var ( 13 | fileType string 14 | ) 15 | 16 | var DecryptCommand = &cobra.Command{ 17 | Use: "decrypt", 18 | Short: "decrypt a file", 19 | Args: cobra.ExactArgs(1), 20 | Run: func(cmd *cobra.Command, args []string) { 21 | f, err := os.Open(args[0]) 22 | if err != nil { 23 | panic(err) 24 | } 25 | defer f.Close() 26 | var d []byte 27 | if fileType == "character" { 28 | _, d = character.Decrypt(f, "pc") 29 | } else if fileType == "profile" { 30 | _, d = profile.Decrypt(f, "pc") 31 | } else { 32 | log.Fatalln("invalid file type") 33 | } 34 | _, err = os.Stdout.Write(d) 35 | }, 36 | } 37 | 38 | func init() { 39 | rootCmd.AddCommand(DecryptCommand) 40 | DecryptCommand.PersistentFlags().StringVarP(&fileType, "type", "t", "character", "character|profile") 41 | } 42 | -------------------------------------------------------------------------------- /cmd/deserialize.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 NAME HERE 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package cmd 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "os" 22 | 23 | "github.com/cfi2017/bl3-save-core/pkg/character" 24 | "github.com/cfi2017/bl3-save-core/pkg/pb" 25 | "github.com/cfi2017/bl3-save-core/pkg/profile" 26 | "github.com/cfi2017/bl3-save-core/pkg/shared" 27 | "github.com/spf13/cobra" 28 | "gopkg.in/yaml.v2" 29 | ) 30 | 31 | var ( 32 | format string 33 | isProfile bool 34 | outputFormat string 35 | ) 36 | 37 | // deserializeCmd represents the deserialize command 38 | var DeserializeCmd = &cobra.Command{ 39 | Use: "deserialize", 40 | Short: "Deserialize a .sav file.", 41 | Long: `Deserialize a .sav file. 42 | 43 | Tries to best-guess the sav file format (profile or character) based on the files name. 44 | Override with --format 45 | `, 46 | Args: cobra.ExactArgs(1), 47 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { 48 | if format != "" { 49 | if format == "profile" { 50 | isProfile = true 51 | } else if format == "character" { 52 | isProfile = false 53 | } else { 54 | return errors.New("unknown format option") 55 | } 56 | } else { 57 | isProfile = shared.GuessIsProfileSav(args[0]) 58 | } 59 | return nil 60 | }, 61 | Run: func(cmd *cobra.Command, args []string) { 62 | f, err := os.Open(args[0]) 63 | if err != nil { 64 | panic(err) 65 | } 66 | 67 | if isProfile { 68 | s, p, err := profile.Deserialize(f, "pc") 69 | if err != nil { 70 | panic(err) 71 | } 72 | r := struct { 73 | Sav shared.SavFile 74 | Profile pb.Profile 75 | }{s, p} 76 | bs, err := yaml.Marshal(r) 77 | if err != nil { 78 | panic(err) 79 | } 80 | fmt.Print(string(bs)) 81 | } else { 82 | s, c, err := character.Deserialize(f, "pc") 83 | if err != nil { 84 | panic(err) 85 | } 86 | r := struct { 87 | Sav shared.SavFile 88 | Character pb.Character 89 | }{s, c} 90 | bs, err := yaml.Marshal(r) 91 | if err != nil { 92 | panic(err) 93 | } 94 | fmt.Print(string(bs)) 95 | } 96 | 97 | }, 98 | } 99 | 100 | func init() { 101 | rootCmd.AddCommand(DeserializeCmd) 102 | DeserializeCmd.PersistentFlags().StringVarP(&format, "format", "f", "", "format ") 103 | DeserializeCmd.PersistentFlags().StringVarP(&outputFormat, "output", "o", "json", "output ") 104 | // Here you will define your flags and configuration settings. 105 | 106 | // Cobra supports Persistent Flags which will work for this command 107 | // and all subcommands, e.g.: 108 | // deserializeCmd.PersistentFlags().String("foo", "", "A help for foo") 109 | 110 | // Cobra supports local flags which will only run when this command 111 | // is called directly, e.g.: 112 | // deserializeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 113 | } 114 | -------------------------------------------------------------------------------- /cmd/items.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bufio" 5 | "encoding/base64" 6 | "encoding/hex" 7 | "encoding/json" 8 | "io" 9 | "os" 10 | "strings" 11 | 12 | "github.com/cfi2017/bl3-save-core/pkg/assets" 13 | "github.com/cfi2017/bl3-save-core/pkg/character" 14 | "github.com/cfi2017/bl3-save-core/pkg/item" 15 | "github.com/cfi2017/bl3-save-core/pkg/pb" 16 | "github.com/spf13/cobra" 17 | ) 18 | 19 | var ( 20 | items []string 21 | ) 22 | 23 | var ItemsCommand = &cobra.Command{ 24 | Use: "items", 25 | Args: cobra.ExactArgs(1), 26 | Run: func(cmd *cobra.Command, args []string) { 27 | // first, grab the character 28 | f, err := os.Open(args[0]) 29 | if err != nil { 30 | cmd.PrintErrf("couldn't open character: %v\n", err) 31 | } 32 | s, c, err := character.Deserialize(f, "pc") 33 | if err != nil { 34 | cmd.PrintErr(err) 35 | return 36 | } 37 | err = f.Close() 38 | if err != nil { 39 | cmd.PrintErr(err) 40 | return 41 | } 42 | 43 | for _, file := range files { 44 | var reader io.Reader 45 | var err error 46 | if file != "-" { 47 | reader, err = os.Open(file) 48 | if err != nil { 49 | cmd.PrintErr(err) 50 | return 51 | } 52 | } else { 53 | reader = os.Stdin 54 | } 55 | scanner := bufio.NewScanner(reader) 56 | for scanner.Scan() { 57 | items = append(items, scanner.Text()) 58 | } 59 | if err := scanner.Err(); err != nil { 60 | cmd.PrintErr(err) 61 | return 62 | } 63 | if f, ok := reader.(*os.File); ok { 64 | err = f.Close() 65 | if err != nil { 66 | cmd.PrintErr(err) 67 | return 68 | } 69 | } 70 | } 71 | 72 | for i := range items { 73 | var anoints = make([]string, 0) 74 | if parts := strings.Split(items[i], " "); len(parts) > 1 { 75 | var anointments Anointments 76 | bs, err := base64.StdEncoding.DecodeString(parts[1]) 77 | if err != nil { 78 | cmd.PrintErr(err) 79 | return 80 | } 81 | err = json.Unmarshal(bs, &anointments) 82 | if anointments.CopyType != "anointment" { 83 | cmd.PrintErrln("not a valid anointment code") 84 | return 85 | } 86 | for _, i := range anointments.Components { 87 | anoints = append(anoints, item.DmKeyToInvKey(anointments.ComponentNames[i], 88 | assets.GetDB().GetData("InventoryGenericPartData").Assets)) 89 | } 90 | items[i] = parts[0] 91 | } 92 | if strings.HasPrefix(items[i], "bl3(") || strings.HasPrefix(items[i], "BL3(") { 93 | // assume bl3 format, verify and add 94 | } else { 95 | // try to convert base64 96 | bs, err := base64.StdEncoding.DecodeString(items[i]) 97 | if err != nil { 98 | cmd.PrintErr(err) 99 | return 100 | } 101 | var dmi item.DigitalMarineItem 102 | err = json.Unmarshal(bs, &dmi) 103 | if err == nil { 104 | gi := item.DmToGibbed(dmi) 105 | bs, err = item.Serialize(gi, 0) // encrypt with 0 seed 106 | if err != nil { 107 | cmd.PrintErr(err) 108 | return 109 | } 110 | items[i] = hex.EncodeToString(bs) 111 | } 112 | // else assume bl3 format, do nothing for now 113 | } 114 | 115 | items[i] = strings.TrimPrefix(items[i], "bl3(") 116 | items[i] = strings.TrimPrefix(items[i], "BL3(") 117 | items[i] = strings.TrimSuffix(items[i], ")") 118 | 119 | bs, err := base64.StdEncoding.DecodeString(items[i]) 120 | if err != nil { 121 | cmd.PrintErr(err) 122 | return 123 | } 124 | // we don't actually care about the item, 125 | // just that it deserializes correctly 126 | bsc := make([]byte, len(bs)) 127 | copy(bsc, bs) 128 | current, err := item.Deserialize(bsc) 129 | if err != nil { 130 | cmd.PrintErr(err) 131 | return 132 | } 133 | current.Generics = append(current.Generics, anoints...) 134 | bs, err = item.Serialize(current, 0) 135 | if err != nil { 136 | cmd.PrintErr(err) 137 | return 138 | } 139 | c.InventoryItems = append(c.InventoryItems, &pb.OakInventoryItemSaveGameData{ 140 | ItemSerialNumber: bs, 141 | PickupOrderIndex: 200, // set static, idk what this does 142 | Flags: 1, // flag 1 should be "new" 143 | WeaponSkinPath: "", // no skin applied 144 | DevelopmentSaveData: nil, 145 | }) 146 | } 147 | 148 | // first, grab the character 149 | f, err = os.Create(args[0]) 150 | if err != nil { 151 | cmd.PrintErrf("couldn't create character: %v\n", err) 152 | } 153 | character.Serialize(f, s, c, "pc") 154 | err = f.Close() 155 | if err != nil { 156 | cmd.PrintErr(err) 157 | return 158 | } 159 | 160 | }, 161 | } 162 | 163 | func init() { 164 | rootCmd.AddCommand(ItemsCommand) 165 | ItemsCommand.PersistentFlags().StringSliceVar(&files, "from-file", []string{}, "import items from file (- for stdin)") 166 | ItemsCommand.PersistentFlags().StringSliceVar(&items, "from-literal", []string{}, "import item") 167 | } 168 | -------------------------------------------------------------------------------- /cmd/list.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 NAME HERE 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package cmd 17 | 18 | import ( 19 | "fmt" 20 | 21 | "github.com/spf13/cobra" 22 | ) 23 | 24 | // listCmd represents the list command 25 | var listCmd = &cobra.Command{ 26 | Use: "list", 27 | Short: "List your characters", 28 | Long: `A longer description that spans multiple lines and likely contains examples 29 | and usage of using your command. For example: 30 | 31 | Cobra is a CLI library for Go that empowers applications. 32 | This application is a tool to generate the needed files 33 | to quickly create a Cobra application.`, 34 | Run: func(cmd *cobra.Command, args []string) { 35 | fmt.Println("list called") 36 | }, 37 | } 38 | 39 | func init() { 40 | rootCmd.AddCommand(listCmd) 41 | 42 | // Here you will define your flags and configuration settings. 43 | 44 | // Cobra supports Persistent Flags which will work for this command 45 | // and all subcommands, e.g.: 46 | // listCmd.PersistentFlags().String("foo", "", "A help for foo") 47 | 48 | // Cobra supports local flags which will only run when this command 49 | // is called directly, e.g.: 50 | // listCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 51 | } 52 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 NAME HERE 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package cmd 17 | 18 | import ( 19 | "fmt" 20 | "os" 21 | 22 | "github.com/cfi2017/bl3-save-core/pkg/assets" 23 | "github.com/cfi2017/bl3-save-core/pkg/shared" 24 | assets2 "github.com/cfi2017/bl3-save/internal/assets" 25 | "github.com/cfi2017/bl3-save/internal/server" 26 | "github.com/mitchellh/go-homedir" 27 | "github.com/spf13/cobra" 28 | "github.com/spf13/viper" 29 | ) 30 | 31 | var cfgFile string 32 | 33 | var ( 34 | insecure bool 35 | defaultPwd string 36 | useCachedAssets bool 37 | ) 38 | 39 | // rootCmd represents the base command when called without any subcommands 40 | var rootCmd = &cobra.Command{ 41 | Use: "bl3-save", 42 | Short: "A brief description of your application", 43 | Long: `A longer description that spans multiple lines and likely contains 44 | examples and usage of using your application. For example: 45 | 46 | Cobra is a CLI library for Go that empowers applications. 47 | This application is a tool to generate the needed files 48 | to quickly create a Cobra application.`, 49 | // Uncomment the following line if your bare application 50 | // has an action associated with it: 51 | Run: func(cmd *cobra.Command, args []string) { 52 | shared.OpenBrowser("https://bl3.swiss.dev/") 53 | opts := server.Options{} 54 | opts.Insecure = insecure 55 | opts.DefaultPwd = defaultPwd 56 | if err := server.Start(opts); err != nil { 57 | panic(err) 58 | } 59 | }, 60 | PersistentPreRun: func(cmd *cobra.Command, args []string) { 61 | if useCachedAssets { 62 | assets.DefaultAssetLoader = &assets.StaticFileAssetLoader{} 63 | } else { 64 | assets.DefaultAssetLoader = assets2.HttpAssetsLoader{} 65 | } 66 | }, 67 | } 68 | 69 | // Execute adds all child commands to the root command and sets flags appropriately. 70 | // This is called by main.main(). It only needs to happen once to the rootCmd. 71 | func Execute() { 72 | if err := rootCmd.Execute(); err != nil { 73 | fmt.Println(err) 74 | os.Exit(1) 75 | } 76 | } 77 | 78 | func init() { 79 | cobra.OnInitialize(initConfig) 80 | // Here you will define your flags and configuration settings. 81 | // Cobra supports persistent flags, which, if defined here, 82 | // will be global for your application. 83 | 84 | rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.bl3-save.yaml)") 85 | rootCmd.PersistentFlags().BoolVar(&useCachedAssets, "use-cached-assets", false, "force using cached assets") 86 | 87 | // Cobra also supports local flags, which will only run 88 | // when this action is called directly. 89 | rootCmd.Flags().BoolVar(&insecure, "insecure", false, "Run server without cors protection") 90 | var currentPwd, _ = os.Getwd() 91 | rootCmd.Flags().StringVar(&defaultPwd, "path", currentPwd, "Path to save file directory") 92 | } 93 | 94 | // initConfig reads in config file and ENV variables if set. 95 | func initConfig() { 96 | if cfgFile != "" { 97 | // Use config file from the flag. 98 | viper.SetConfigFile(cfgFile) 99 | } else { 100 | // Find home directory. 101 | home, err := homedir.Dir() 102 | if err != nil { 103 | fmt.Println(err) 104 | os.Exit(1) 105 | } 106 | 107 | // Search config in home directory with name ".bl3-save" (without extension). 108 | viper.AddConfigPath(home) 109 | viper.SetConfigName(".bl3-save") 110 | } 111 | 112 | viper.AutomaticEnv() // read in environment variables that match 113 | 114 | // If a config file is found, read it in. 115 | if err := viper.ReadInConfig(); err == nil { 116 | fmt.Println("Using config file:", viper.ConfigFileUsed()) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /cmd/serialize.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 NAME HERE 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package cmd 17 | 18 | import ( 19 | "fmt" 20 | 21 | "github.com/spf13/cobra" 22 | ) 23 | 24 | // serializeCmd represents the serialize command 25 | var serializeCmd = &cobra.Command{ 26 | Use: "serialize", 27 | Short: "A brief description of your command", 28 | Long: `A longer description that spans multiple lines and likely contains examples 29 | and usage of using your command. For example: 30 | 31 | Cobra is a CLI library for Go that empowers applications. 32 | This application is a tool to generate the needed files 33 | to quickly create a Cobra application.`, 34 | Run: func(cmd *cobra.Command, args []string) { 35 | fmt.Println("serialize called") 36 | }, 37 | } 38 | 39 | func init() { 40 | rootCmd.AddCommand(serializeCmd) 41 | 42 | // Here you will define your flags and configuration settings. 43 | 44 | // Cobra supports Persistent Flags which will work for this command 45 | // and all subcommands, e.g.: 46 | // serializeCmd.PersistentFlags().String("foo", "", "A help for foo") 47 | 48 | // Cobra supports local flags which will only run when this command 49 | // is called directly, e.g.: 50 | // serializeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 51 | } 52 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cfi2017/bl3-save 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/cfi2017/bl3-save-core v1.3.1 7 | github.com/gin-contrib/cors v1.3.1 8 | github.com/gin-gonic/gin v1.6.2 9 | github.com/golang/protobuf v1.5.2 // indirect 10 | github.com/mitchellh/go-homedir v1.1.0 11 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 12 | github.com/modern-go/reflect2 v1.0.1 // indirect 13 | github.com/spf13/cobra v0.0.7 14 | github.com/spf13/viper v1.6.2 15 | golang.org/x/sys v0.0.0-20200408040146-ea54a3c99b9b // indirect 16 | google.golang.org/protobuf v1.27.1 // indirect 17 | gopkg.in/yaml.v2 v2.2.8 18 | ) 19 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= 3 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 4 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 5 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 6 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 7 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 8 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 9 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 10 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 11 | github.com/cfi2017/bl3-save-core v1.1.3 h1:42g6aYjUtjyqcoua8q09VtK5uzZ39WKMWfLOgCTVALI= 12 | github.com/cfi2017/bl3-save-core v1.1.3/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 13 | github.com/cfi2017/bl3-save-core v1.1.4 h1:HkcBik7W3lE/iFrKjen1rLT+ZTx8KUHR2ffy7emH2vY= 14 | github.com/cfi2017/bl3-save-core v1.1.4/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 15 | github.com/cfi2017/bl3-save-core v1.1.5 h1:Bt6949v9j6NhdKkzG4uqD78Myb+mMDqNdNUwXSAC27I= 16 | github.com/cfi2017/bl3-save-core v1.1.5/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 17 | github.com/cfi2017/bl3-save-core v1.1.6 h1:GpDIfQNHZtmH3alClSS0RTVvOotGjov/Y6QDVul/PA8= 18 | github.com/cfi2017/bl3-save-core v1.1.6/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 19 | github.com/cfi2017/bl3-save-core v1.2.1 h1:AELeXaoIgidgnis+eqT/CtJ1zZ4so4Zc1oDJ+M2yZjI= 20 | github.com/cfi2017/bl3-save-core v1.2.1/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 21 | github.com/cfi2017/bl3-save-core v1.2.4 h1:z2WJWDFidr5+u1WtLGV8cLBBXuEAgNhGnj57bPzo7dc= 22 | github.com/cfi2017/bl3-save-core v1.2.4/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 23 | github.com/cfi2017/bl3-save-core v1.3.0 h1:5Kmxs4ftLtAGV39ei6S7/I1fljVCouy9nRJmhPaYOkk= 24 | github.com/cfi2017/bl3-save-core v1.3.0/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 25 | github.com/cfi2017/bl3-save-core v1.3.1 h1:N8PevzsWp/cEGnKey3ehlkEBfIikTkhf48ghfEo9z94= 26 | github.com/cfi2017/bl3-save-core v1.3.1/go.mod h1:YV/PucmAhOAspofYbsys0dCm8qTAdsPPQuRvjjjjunM= 27 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 28 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 29 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 30 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 31 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 32 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 33 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 34 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 35 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 36 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 37 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 38 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 39 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 40 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 41 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 42 | github.com/gin-contrib/cors v1.3.1 h1:doAsuITavI4IOcd0Y19U4B+O0dNWihRyX//nn4sEmgA= 43 | github.com/gin-contrib/cors v1.3.1/go.mod h1:jjEJ4268OPZUcU7k9Pm653S7lXUGcqMADzFA61xsmDk= 44 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= 45 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= 46 | github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= 47 | github.com/gin-gonic/gin v1.6.2 h1:88crIK23zO6TqlQBt+f9FrPJNKm9ZEr7qjp9vl/d5TM= 48 | github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= 49 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 50 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 51 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 52 | github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= 53 | github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= 54 | github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= 55 | github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= 56 | github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= 57 | github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= 58 | github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= 59 | github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= 60 | github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= 61 | github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= 62 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 63 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 64 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 65 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 66 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 67 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 68 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 69 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 70 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 71 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 72 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 73 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 74 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 75 | github.com/golang/protobuf v1.4.0-rc.4 h1:+EOh4OY6tjM6ZueeUKinl1f0U2820HzQOuf1iqMnsks= 76 | github.com/golang/protobuf v1.4.0-rc.4/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 77 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 78 | github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ= 79 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 80 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 81 | github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= 82 | github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 83 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 84 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 85 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 86 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 87 | github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= 88 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 89 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 90 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 91 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= 92 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 93 | github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 94 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 95 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 96 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 97 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 98 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 99 | github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= 100 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 101 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 102 | github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 103 | github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= 104 | github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 105 | github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= 106 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 107 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 108 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 109 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 110 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 111 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 112 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 113 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 114 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 115 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 116 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 117 | github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= 118 | github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= 119 | github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= 120 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 121 | github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= 122 | github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 123 | github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= 124 | github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= 125 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 126 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 127 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 128 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 129 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 130 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 131 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= 132 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 133 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 134 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 135 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= 136 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 137 | github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= 138 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 139 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 140 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 141 | github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= 142 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 143 | github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= 144 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 145 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 146 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 147 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 148 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 149 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 150 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 151 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 152 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 153 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 154 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 155 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 156 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 157 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 158 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 159 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 160 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= 161 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 162 | github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= 163 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 164 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 165 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 166 | github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= 167 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 168 | github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= 169 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 170 | github.com/spf13/cobra v0.0.7 h1:FfTH+vuMXOas8jmfb5/M7dzEYx7LpcLb7a0LPe34uOU= 171 | github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= 172 | github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= 173 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 174 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 175 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 176 | github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= 177 | github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E= 178 | github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= 179 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 180 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 181 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 182 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 183 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 184 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 185 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 186 | github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= 187 | github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= 188 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 189 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= 190 | github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= 191 | github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= 192 | github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= 193 | github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= 194 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 195 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 196 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 197 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 198 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 199 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 200 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 201 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 202 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 203 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 204 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 205 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 206 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 207 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 208 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 209 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 210 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 211 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 212 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 213 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 214 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 215 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 216 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 217 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= 218 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 219 | golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 220 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= 221 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 222 | golang.org/x/sys v0.0.0-20200408040146-ea54a3c99b9b h1:h03Ur1RlPrGTjua4koYdpGl8W0eYo8p1uI9w7RPlkdk= 223 | golang.org/x/sys v0.0.0-20200408040146-ea54a3c99b9b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 224 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 225 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 226 | golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= 227 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 228 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 229 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 230 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 231 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 232 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 233 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 234 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 235 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 236 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 237 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 238 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 239 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 240 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 241 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 242 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 243 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 244 | google.golang.org/protobuf v1.20.1 h1:ESRXHgpUBG5D2I5mmsQIyYxB/tQIZfSZ8wLyFDf/N/U= 245 | google.golang.org/protobuf v1.20.1/go.mod h1:KqelGeouBkcbcuB3HCk4/YH2tmNLk6YSWA5LIWeI/lY= 246 | google.golang.org/protobuf v1.21.0 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zimw= 247 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 248 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 249 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 250 | google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= 251 | google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 252 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 253 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 254 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 255 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 256 | gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= 257 | gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= 258 | gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= 259 | gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 260 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 261 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 262 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 263 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 264 | gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= 265 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 266 | gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= 267 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 268 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 269 | -------------------------------------------------------------------------------- /internal/assets/asset.go: -------------------------------------------------------------------------------- 1 | package assets 2 | 3 | import ( 4 | "io" 5 | "log" 6 | "net/http" 7 | "os" 8 | "time" 9 | 10 | "github.com/cfi2017/bl3-save-core/pkg/assets" 11 | ) 12 | 13 | var ( 14 | httpClient = http.Client{ 15 | Timeout: time.Second * 30, 16 | } 17 | publisher = "https://bl3.swiss.dev" 18 | ) 19 | 20 | type HttpAssetsLoader struct { 21 | CacheDir string 22 | } 23 | 24 | func (h HttpAssetsLoader) GetDB() assets.PartsDatabase { 25 | return GetDB() 26 | } 27 | 28 | func (h HttpAssetsLoader) GetBtik() map[string]string { 29 | return GetBtik() 30 | } 31 | 32 | func downloadAsset(path, url string) error { 33 | request, err := http.NewRequest("GET", url, nil) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | if fileExists(path) { 39 | t := modTime(path) 40 | request.Header.Add("If-Modified-Since", t.Format(http.TimeFormat)) 41 | } 42 | 43 | r, err := httpClient.Do(request) 44 | if err != nil { 45 | return err 46 | } 47 | defer r.Body.Close() 48 | if r.StatusCode == http.StatusNotModified { 49 | // don't write in this case 50 | return nil 51 | } 52 | log.Printf("downloading newer version of asset to %s\n", path) 53 | f, err := os.Create(path) 54 | if err != nil { 55 | return err 56 | } 57 | defer f.Close() 58 | _, err = io.Copy(f, r.Body) 59 | if err != nil { 60 | return err 61 | } 62 | return nil 63 | } 64 | 65 | func modTime(path string) time.Time { 66 | s, err := os.Stat(path) 67 | if err != nil { 68 | panic(err) 69 | } 70 | return s.ModTime() 71 | } 72 | 73 | func fileExists(file string) bool { 74 | _, err := os.Stat(file) 75 | return !os.IsNotExist(err) 76 | } 77 | -------------------------------------------------------------------------------- /internal/assets/balance_to_inv_key.go: -------------------------------------------------------------------------------- 1 | package assets 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "log" 8 | "os" 9 | "sync" 10 | ) 11 | 12 | var ( 13 | btik map[string]string 14 | btikOnce = sync.Once{} 15 | ) 16 | 17 | func GetBtik() map[string]string { 18 | var err error 19 | btikOnce.Do(func() { 20 | _ = os.MkdirAll("assets", os.ModePerm) 21 | err = downloadAsset("assets/balance_to_inv_key.json", fmt.Sprintf("%s/assets/balance_to_inv_key.json", publisher)) 22 | if err != nil { 23 | log.Println("couldn't download fresh assets") 24 | } 25 | btik, err = loadPartMap("assets/balance_to_inv_key.json") 26 | }) 27 | if err != nil { 28 | panic(err) 29 | } 30 | return btik 31 | } 32 | 33 | func loadPartMap(file string) (m map[string]string, err error) { 34 | bs, err := ioutil.ReadFile(file) 35 | if err != nil { 36 | return 37 | } 38 | err = json.Unmarshal(bs, &m) 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /internal/assets/inventory_raw.go: -------------------------------------------------------------------------------- 1 | package assets 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | "sync" 8 | 9 | "github.com/cfi2017/bl3-save-core/pkg/assets" 10 | ) 11 | 12 | var ( 13 | db assets.PartsDatabase 14 | dbOnce = sync.Once{} 15 | ) 16 | 17 | func GetDB() assets.PartsDatabase { 18 | var err error 19 | dbOnce.Do(func() { 20 | _ = os.MkdirAll("assets", os.ModePerm) 21 | err = downloadAsset("assets/inventory_raw.json", fmt.Sprintf("%s/assets/inventory_raw.json", publisher)) 22 | if err != nil { 23 | log.Println("couldn't download fresh assets") 24 | } 25 | db, err = assets.LoadPartsDatabase("assets/inventory_raw.json") 26 | }) 27 | if err != nil { 28 | panic(err) 29 | } 30 | return db 31 | } 32 | -------------------------------------------------------------------------------- /internal/server/backup.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "time" 8 | ) 9 | 10 | func backup(pwd, id string) { 11 | dumpDir := fmt.Sprintf("%s/backups/%s", pwd, id) 12 | err := os.MkdirAll(dumpDir, os.ModePerm) 13 | if err != nil { 14 | panic(err) 15 | } 16 | 17 | dumpPath := fmt.Sprintf("%s/%s-%v.sav", dumpDir, id, time.Now().Unix()) 18 | 19 | _, err = copyFile(fmt.Sprintf("%s/%s.sav", pwd, id), dumpPath) 20 | if err != nil { 21 | panic(err) 22 | } 23 | } 24 | 25 | func copyFile(src, dst string) (int64, error) { 26 | sourceFileStat, err := os.Stat(src) 27 | if err != nil { 28 | return 0, err 29 | } 30 | if !sourceFileStat.Mode().IsRegular() { 31 | return 0, fmt.Errorf("%s ios not a regular file", src) 32 | } 33 | 34 | source, err := os.Open(src) 35 | if err != nil { 36 | return 0, err 37 | } 38 | defer source.Close() 39 | 40 | destination, err := os.Create(dst) 41 | if err != nil { 42 | return 0, err 43 | } 44 | defer destination.Close() 45 | 46 | return io.Copy(destination, source) 47 | } 48 | -------------------------------------------------------------------------------- /internal/server/character.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "encoding/base64" 5 | "io/ioutil" 6 | "log" 7 | "math" 8 | "os" 9 | "regexp" 10 | 11 | "github.com/cfi2017/bl3-save-core/pkg/character" 12 | "github.com/cfi2017/bl3-save-core/pkg/item" 13 | "github.com/cfi2017/bl3-save-core/pkg/pb" 14 | "github.com/cfi2017/bl3-save-core/pkg/shared" 15 | "github.com/gin-gonic/gin" 16 | ) 17 | 18 | var ( 19 | charPattern = regexp.MustCompile("^([0-9a-fA-F]+)\\.sav$") 20 | ) 21 | 22 | type ItemRequest struct { 23 | Items []item.Item `json:"items"` 24 | Equipped []*pb.EquippedInventorySaveGameData `json:"equipped"` 25 | Active []int32 `json:"active"` 26 | Platform string `json:"platform"` 27 | } 28 | 29 | func listCharacters(c *gin.Context) { 30 | files, err := ioutil.ReadDir(pwd) 31 | if err != nil { 32 | c.AbortWithStatus(500) 33 | return 34 | } 35 | characters := make([]CharInfo, 0) 36 | for _, i := range files { 37 | if !i.IsDir() && charPattern.MatchString(i.Name()) { 38 | char, err := listChar(charPattern.FindStringSubmatch(i.Name())[1]) 39 | if err != nil { 40 | log.Println(err) 41 | c.AbortWithStatus(500) 42 | return 43 | } 44 | characters = append(characters, char) 45 | } 46 | } 47 | c.JSON(200, &characters) 48 | 49 | } 50 | 51 | func getSaveById(id string) (*os.File, error) { 52 | return os.Open(pwd + "/" + id + ".sav") 53 | } 54 | 55 | func getCharacterRequest(c *gin.Context) { 56 | id := c.Param("id") 57 | 58 | f, err := getSaveById(id) 59 | if err != nil { 60 | c.AbortWithStatus(500) 61 | return 62 | } 63 | defer f.Close() 64 | s, char, err := character.Deserialize(f, "pc") 65 | if err != nil { 66 | log.Printf("error deserializing save: %v", err) 67 | c.AbortWithStatusJSON(500, &err) 68 | return 69 | } 70 | // workaround for invalid json parsing values 71 | for _, d := range char.GbxZoneMapFodSaveGameData.LevelData { 72 | if d.DiscoveryPercentage > math.MaxFloat32 { 73 | d.DiscoveryPercentage = -1 74 | } 75 | } 76 | c.JSON(200, &struct { 77 | Save shared.SavFile `json:"save"` 78 | Character pb.Character `json:"character"` 79 | Platform string `json:"platform"` 80 | }{Save: s, Character: char, Platform: "pc"}) 81 | 82 | } 83 | 84 | func updateCharacterRequest(c *gin.Context) { 85 | id := c.Param("id") 86 | 87 | var d struct { 88 | Save shared.SavFile `json:"save"` 89 | Character pb.Character `json:"character"` 90 | } 91 | err := c.BindJSON(&d) 92 | if err != nil { 93 | c.AbortWithStatus(500) 94 | return 95 | } 96 | 97 | // workaround for invalid json parsing values 98 | for _, d := range d.Character.GbxZoneMapFodSaveGameData.LevelData { 99 | if d.DiscoveryPercentage == -1 { 100 | d.DiscoveryPercentage = math.Float32frombits(0x7F800000) // inf 101 | } 102 | } 103 | 104 | backup(pwd, id) 105 | f, err := os.Create(pwd + "/" + id + ".sav") 106 | if err != nil { 107 | c.AbortWithStatus(500) 108 | return 109 | } 110 | defer f.Close() 111 | character.Serialize(f, d.Save, d.Character, "pc") 112 | c.Status(204) 113 | return 114 | } 115 | 116 | type CharInfo struct { 117 | ID string `json:"id"` 118 | Name string `json:"name"` 119 | Experience int32 `json:"experience"` 120 | } 121 | 122 | func listChar(id string) (char CharInfo, err error) { 123 | f, err := getSaveById(id) 124 | char.ID = id 125 | if err != nil { 126 | return 127 | } 128 | defer f.Close() 129 | _, c, err := character.Deserialize(f, "pc") 130 | if err != nil { 131 | return 132 | } 133 | char.Name = c.PreferredCharacterName 134 | char.Experience = c.ExperiencePoints 135 | return 136 | } 137 | 138 | func getItemsRequest(c *gin.Context) { 139 | id := c.Param("id") 140 | f, err := getSaveById(id) 141 | if err != nil { 142 | c.AbortWithStatus(500) 143 | } 144 | _, char, err := character.Deserialize(f, "pc") 145 | if err != nil { 146 | log.Printf("error deserializing save: %v", err) 147 | c.AbortWithStatusJSON(500, &err) 148 | return 149 | } 150 | items := make([]item.Item, 0) 151 | for _, data := range char.InventoryItems { 152 | d := make([]byte, len(data.ItemSerialNumber)) 153 | copy(d, data.ItemSerialNumber) 154 | i, err := item.Deserialize(d) 155 | if err != nil { 156 | log.Println(err) 157 | log.Println(base64.StdEncoding.EncodeToString(data.ItemSerialNumber)) 158 | // c.AbortWithStatus(500) 159 | // return 160 | } 161 | i.Wrapper = data 162 | items = append(items, i) 163 | } 164 | ir := ItemRequest{ 165 | Items: items, 166 | Equipped: char.EquippedInventoryList, 167 | Active: char.ActiveWeaponList, 168 | Platform: "pc", 169 | } 170 | c.JSON(200, &ir) 171 | return 172 | } 173 | 174 | func updateItemsRequest(c *gin.Context) { 175 | 176 | id := c.Param("id") 177 | f, err := getSaveById(id) 178 | if err != nil { 179 | log.Printf("error getting save: %v", err) 180 | c.AbortWithStatusJSON(500, &err) 181 | return 182 | } 183 | s, char, err := character.Deserialize(f, "pc") 184 | if err != nil { 185 | log.Printf("error deserializing save: %v", err) 186 | c.AbortWithStatusJSON(500, &err) 187 | return 188 | } 189 | err = f.Close() 190 | if err != nil { 191 | log.Printf("error deserializing save: %v", err) 192 | c.AbortWithStatusJSON(500, &err) 193 | return 194 | } 195 | var ir ItemRequest 196 | err = c.BindJSON(&ir) 197 | if err != nil { 198 | log.Printf("error deserializing request json: %v", err) 199 | c.AbortWithStatusJSON(500, &err) 200 | return 201 | } 202 | backup(pwd, id) 203 | char.InventoryItems, err = itemsToPBArray(ir.Items) 204 | if err != nil { 205 | log.Printf("error converting items to save format: %v", err) 206 | c.AbortWithStatusJSON(500, &err) 207 | return 208 | } 209 | char.ActiveWeaponList = ir.Active 210 | char.EquippedInventoryList = ir.Equipped 211 | f, err = os.Create(pwd + "/" + id + ".sav") 212 | if err != nil { 213 | c.AbortWithStatus(500) 214 | return 215 | } 216 | defer f.Close() 217 | character.Serialize(f, s, char, "pc") 218 | c.Status(204) 219 | return 220 | 221 | } 222 | 223 | func itemsToPBArray(items []item.Item) ([]*pb.OakInventoryItemSaveGameData, error) { 224 | result := make([]*pb.OakInventoryItemSaveGameData, len(items)) 225 | for index, i := range items { 226 | result[index] = i.Wrapper 227 | seed, err := item.GetSeedFromSerial(i.Wrapper.ItemSerialNumber) 228 | if err != nil { 229 | // set seed to be 0 230 | seed = 0 231 | } 232 | if i.Balance == "" { 233 | // sanity check, if the balance is empty, just write the original item back 234 | continue 235 | } 236 | result[index].ItemSerialNumber, err = item.Serialize(i, seed) 237 | if err != nil { 238 | return nil, err 239 | } 240 | } 241 | return result, nil 242 | } 243 | -------------------------------------------------------------------------------- /internal/server/convert.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/json" 6 | "log" 7 | "regexp" 8 | "strings" 9 | 10 | "github.com/cfi2017/bl3-save-core/pkg/item" 11 | "github.com/cfi2017/bl3-save-core/pkg/pb" 12 | "github.com/gin-gonic/gin" 13 | ) 14 | 15 | var ( 16 | bl3CodeRegexp = regexp.MustCompile("(bl|BL)3\\(([A-Za-z0-9+/=]+)\\)") 17 | ) 18 | 19 | func convertItem(c *gin.Context) { 20 | 21 | var request struct { 22 | Base64 string `json:"base64"` 23 | } 24 | err := c.BindJSON(&request) 25 | if err != nil { 26 | log.Println(err) 27 | c.AbortWithStatusJSON(500, err) 28 | return 29 | } 30 | request.Base64 = strings.TrimSpace(request.Base64) 31 | bs, err := base64.StdEncoding.DecodeString(request.Base64) 32 | if err != nil { 33 | // try extracting bl3 codes 34 | codes, err := extractBL3Codes(request.Base64) 35 | if err != nil { 36 | log.Println(err) 37 | c.AbortWithStatusJSON(500, err) 38 | return 39 | } 40 | items := make([]item.Item, len(codes)) 41 | for index, code := range codes { 42 | bs, err := base64.StdEncoding.DecodeString(code) 43 | if err != nil { 44 | log.Println(err) 45 | c.AbortWithStatusJSON(500, err) 46 | return 47 | } 48 | i, err := item.Deserialize(bs) 49 | if err != nil { 50 | log.Printf("error in bl3(%s): %v", code, err) 51 | c.AbortWithStatusJSON(500, err) 52 | return 53 | } 54 | i.Wrapper = &pb.OakInventoryItemSaveGameData{ 55 | ItemSerialNumber: bs, 56 | PickupOrderIndex: 200, 57 | Flags: 3, 58 | WeaponSkinPath: "", 59 | DevelopmentSaveData: nil, 60 | } 61 | items[index] = i 62 | } 63 | c.JSON(200, &items) 64 | return 65 | } 66 | var dmi item.DigitalMarineItem 67 | err = json.Unmarshal(bs, &dmi) 68 | if err != nil { 69 | log.Println(err) 70 | c.AbortWithStatusJSON(500, err) 71 | return 72 | } 73 | i := item.DmToGibbed(dmi) 74 | bs, err = item.Serialize(i, 0) // encrypt with 0 seed 75 | if err != nil { 76 | c.AbortWithStatusJSON(500, err) 77 | return 78 | } 79 | i.Wrapper = &pb.OakInventoryItemSaveGameData{ 80 | ItemSerialNumber: bs, 81 | PickupOrderIndex: 200, 82 | Flags: 3, 83 | WeaponSkinPath: "", 84 | DevelopmentSaveData: nil, 85 | } 86 | c.JSON(200, &[]item.Item{i}) 87 | return 88 | } 89 | 90 | func extractBL3Codes(text string) (codes []string, err error) { 91 | matches := bl3CodeRegexp.FindAllStringSubmatch(text, -1) 92 | codes = make([]string, len(matches)) 93 | for i, match := range matches { 94 | codes[i] = match[2] 95 | } 96 | return 97 | } 98 | -------------------------------------------------------------------------------- /internal/server/convert_test.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "encoding/base64" 5 | "log" 6 | "strings" 7 | "testing" 8 | "time" 9 | 10 | "github.com/cfi2017/bl3-save-core/pkg/assets" 11 | "github.com/cfi2017/bl3-save-core/pkg/item" 12 | "github.com/cfi2017/bl3-save-core/pkg/pb" 13 | assets2 "github.com/cfi2017/bl3-save/internal/assets" 14 | ) 15 | 16 | const ( 17 | code = "BL3(AwAAAACQ/IA5VpSBEOCjjgcksmA0JBQNp7RKQaFQKBQKhUKh0Eaj0Wg0Go1Go9FoNBqNRqPRaDQajUaj0Wg0Go1GQ+5hhAAAAAAAAAAAAA==)" 18 | iterations = 1000 19 | ) 20 | 21 | func TestConvert(t *testing.T) { 22 | 23 | // setup 24 | assets.DefaultAssetLoader = assets2.HttpAssetsLoader{} 25 | text := strings.Repeat(code, iterations) 26 | text += "asdfasdf asdf\n some random stuff" 27 | codes, err := extractBL3Codes(text) 28 | if err != nil { 29 | t.Fatal(err) 30 | } 31 | 32 | start := time.Now() 33 | 34 | items := make([]item.Item, len(codes)) 35 | for index, code := range codes { 36 | bs, err := base64.StdEncoding.DecodeString(code) 37 | if err != nil { 38 | log.Fatal(err) 39 | } 40 | i, err := item.Deserialize(bs) 41 | if err != nil { 42 | t.Fatal(err) 43 | } 44 | i.Wrapper = &pb.OakInventoryItemSaveGameData{ 45 | ItemSerialNumber: bs, 46 | PickupOrderIndex: 200, 47 | Flags: 3, 48 | WeaponSkinPath: "", 49 | DevelopmentSaveData: nil, 50 | } 51 | items[index] = i 52 | } 53 | 54 | t.Logf("Deserialized %d items in %v", len(items), time.Since(start)) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /internal/server/crossplatform.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "github.com/cfi2017/bl3-save-core/pkg/pb" 7 | "github.com/cfi2017/bl3-save-core/pkg/shared" 8 | "io" 9 | "io/ioutil" 10 | ) 11 | 12 | var ErrInvalidSavFile = errors.New("invalid save file") 13 | 14 | type Platforms map[string]shared.Magic 15 | 16 | type DeserializeFunc func(reader io.Reader, magic shared.Magic) (shared.SavFile, pb.Character, error) 17 | 18 | func TryDeserialize(deserializeFunc DeserializeFunc, platforms Platforms, reader io.Reader) (s shared.SavFile, char pb.Character, platform string, err error) { 19 | bs, err := ioutil.ReadAll(reader) 20 | if err != nil { 21 | return shared.SavFile{}, pb.Character{}, "", err 22 | } 23 | for p, magic := range platforms { 24 | reader = bytes.NewReader(bs) 25 | s, char, err = deserializeFunc(reader, magic) 26 | platform = p 27 | if err == nil { 28 | return 29 | } 30 | } 31 | return shared.SavFile{}, pb.Character{}, "", ErrInvalidSavFile 32 | } 33 | -------------------------------------------------------------------------------- /internal/server/options.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | type Options struct { 4 | Insecure bool 5 | DefaultPwd string 6 | } 7 | -------------------------------------------------------------------------------- /internal/server/profile.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "encoding/base64" 5 | "log" 6 | "os" 7 | 8 | "github.com/cfi2017/bl3-save-core/pkg/item" 9 | "github.com/cfi2017/bl3-save-core/pkg/pb" 10 | "github.com/cfi2017/bl3-save-core/pkg/profile" 11 | "github.com/cfi2017/bl3-save-core/pkg/shared" 12 | "github.com/gin-gonic/gin" 13 | ) 14 | 15 | func getProfile(c *gin.Context) { 16 | f, err := os.Open(pwd + "/profile.sav") 17 | if err != nil { 18 | c.AbortWithStatus(500) 19 | return 20 | } 21 | defer f.Close() 22 | s, p, err := profile.Deserialize(f, "pc") 23 | if err != nil { 24 | log.Printf("error deserializing save: %v", err) 25 | c.AbortWithStatusJSON(500, &err) 26 | return 27 | } 28 | c.JSON(200, struct { 29 | Save shared.SavFile `json:"save"` 30 | Profile pb.Profile `json:"profile"` 31 | }{Save: s, Profile: p}) 32 | } 33 | 34 | func updateProfile(c *gin.Context) { 35 | var d struct { 36 | Save shared.SavFile `json:"save"` 37 | Profile pb.Profile `json:"profile"` 38 | } 39 | err := c.BindJSON(&d) 40 | if err != nil { 41 | _ = c.AbortWithError(500, err) 42 | return 43 | } 44 | backup(pwd, "profile") 45 | f, err := os.Create(pwd + "/profile.sav") 46 | if err != nil { 47 | _ = c.AbortWithError(500, err) 48 | return 49 | } 50 | defer f.Close() 51 | profile.Serialize(f, d.Save, d.Profile, "pc") 52 | c.Status(204) 53 | return 54 | 55 | } 56 | 57 | func getBankRequest(c *gin.Context) { 58 | f, err := os.Open(pwd + "/profile.sav") 59 | if err != nil { 60 | c.AbortWithStatus(500) 61 | return 62 | } 63 | defer f.Close() 64 | _, p, err := profile.Deserialize(f, "pc") 65 | if err != nil { 66 | log.Printf("error deserializing save: %v", err) 67 | c.AbortWithStatusJSON(500, &err) 68 | return 69 | } 70 | items := make([]item.Item, 0) 71 | for _, data := range p.BankInventoryList { 72 | d := make([]byte, len(data)) 73 | copy(d, data) 74 | i, err := item.Deserialize(d) 75 | if err != nil { 76 | log.Println(err) 77 | log.Println(base64.StdEncoding.EncodeToString(data)) 78 | // c.AbortWithStatus(500) 79 | // return 80 | } 81 | i.Wrapper = &pb.OakInventoryItemSaveGameData{ 82 | ItemSerialNumber: data, 83 | } 84 | items = append(items, i) 85 | } 86 | c.JSON(200, &items) 87 | return 88 | } 89 | 90 | func updateBankRequest(c *gin.Context) { 91 | f, err := os.Open(pwd + "/profile.sav") 92 | if err != nil { 93 | c.AbortWithStatus(500) 94 | return 95 | } 96 | s, p, err := profile.Deserialize(f, "pc") 97 | if err != nil { 98 | log.Printf("error deserializing save: %v", err) 99 | c.AbortWithStatusJSON(500, &err) 100 | return 101 | } 102 | err = f.Close() 103 | if err != nil { 104 | c.AbortWithStatus(500) 105 | return 106 | } 107 | var items []item.Item 108 | err = c.BindJSON(&items) 109 | if err != nil { 110 | c.AbortWithStatus(500) 111 | return 112 | } 113 | backup(pwd, "profile") 114 | pba, err := itemsToPBArray(items) 115 | p.BankInventoryList = make([][]byte, len(pba)) 116 | for i := range pba { 117 | p.BankInventoryList[i] = pba[i].ItemSerialNumber 118 | } 119 | f, err = os.Create(pwd + "/profile.sav") 120 | if err != nil { 121 | c.AbortWithStatus(500) 122 | return 123 | } 124 | defer f.Close() 125 | profile.Serialize(f, s, p, "pc") 126 | c.Status(204) 127 | return 128 | 129 | } 130 | -------------------------------------------------------------------------------- /internal/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "os" 5 | "strings" 6 | "time" 7 | 8 | "github.com/gin-contrib/cors" 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | var ( 13 | pwd string 14 | BuildVersion = "" 15 | BuildCommit = "" 16 | BuildDate = "" 17 | BuiltBy = "" 18 | ) 19 | 20 | func Start(opts Options) error { 21 | gin.SetMode(gin.ReleaseMode) 22 | r := gin.New() 23 | r.Use(gin.LoggerWithWriter(os.Stderr, "/stats"), gin.Recovery()) 24 | cfg := cors.Config{ 25 | AllowMethods: []string{"GET", "POST"}, 26 | AllowHeaders: []string{"Origin", "Content-Type"}, 27 | ExposeHeaders: []string{"Content-Length"}, 28 | AllowCredentials: false, 29 | MaxAge: 12 * time.Hour, 30 | } 31 | 32 | if opts.Insecure { 33 | cfg.AllowAllOrigins = true 34 | } else { 35 | cfg.AllowOrigins = []string{"https://bl3.swiss.dev", "http://localhost:4200"} 36 | } 37 | pwd = opts.DefaultPwd 38 | r.Use(cors.New(cfg)) 39 | 40 | r.GET("/stats", func(c *gin.Context) { 41 | _, err := os.Stat(pwd + "/profile.sav") 42 | c.JSON(200, &struct { 43 | Pwd string `json:"pwd"` 44 | HasProfile bool `json:"hasProfile"` 45 | BuildVersion string `json:"buildVersion"` 46 | BuildCommit string `json:"buildCommit"` 47 | BuildDate string `json:"buildDate"` 48 | BuiltBy string `json:"builtBy"` 49 | }{ 50 | Pwd: pwd, 51 | HasProfile: err == nil && !os.IsNotExist(err), 52 | BuildVersion: BuildVersion, 53 | BuildCommit: BuildCommit, 54 | BuildDate: BuildDate, 55 | BuiltBy: BuiltBy, 56 | }) 57 | }) 58 | 59 | r.POST("/cd", func(c *gin.Context) { 60 | var body struct { 61 | Pwd string `json:"pwd" binding:"required"` 62 | } 63 | err := c.Bind(&body) 64 | if err != nil { 65 | return 66 | } 67 | pwd = strings.TrimSuffix(body.Pwd, "/") 68 | c.JSON(200, struct { 69 | Pwd string `json:"pwd"` 70 | }{Pwd: pwd}) 71 | }) 72 | 73 | r.GET("/profile", getProfile) 74 | r.POST("/profile", updateProfile) 75 | r.GET("/profile/bank", getBankRequest) 76 | r.POST("/profile/bank", updateBankRequest) 77 | 78 | r.GET("/characters", listCharacters) 79 | r.GET("/characters/:id", getCharacterRequest) 80 | r.POST("/characters/:id", updateCharacterRequest) 81 | 82 | r.GET("/characters/:id/items", getItemsRequest) 83 | r.POST("/characters/:id/items", updateItemsRequest) 84 | 85 | r.POST("/convert", convertItem) 86 | 87 | return r.Run(":5050") 88 | } 89 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 NAME HERE 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package main 17 | 18 | import ( 19 | "github.com/cfi2017/bl3-save/cmd" 20 | "github.com/cfi2017/bl3-save/internal/server" 21 | "github.com/spf13/cobra" 22 | ) 23 | 24 | var ( 25 | version = "v100.0.0" 26 | commit = "" 27 | date = "" 28 | builtBy = "local" 29 | ) 30 | 31 | func main() { 32 | server.BuildVersion = version 33 | server.BuildCommit = commit 34 | server.BuildDate = date 35 | server.BuiltBy = builtBy 36 | cobra.MousetrapHelpText = "" 37 | cmd.Execute() 38 | } 39 | --------------------------------------------------------------------------------