How to use skipStart method of main Package

Best Syzkaller code snippet using main.skipStart

CaptchaParser.go

Source:CaptchaParser.go Github

copy

Full Screen

1// Dependencies :2// github.com/hotei/bmp3// How to install:4// go get github.com/hotei/bmp5// USAGE:6// package main7// import (8// "CaptchaParser"9// "fmt"10// "log"11// "os"12// )13// func main() {14// reader, err := os.Open("captcha.bmp")15// if err != nil {16// log.Fatal("File error")17// }18// output := captcha.GetCaptcha(reader)19// fmt.Println(output)20// }21package captcha22import (23 "github.com/hotei/bmp"24 "image"25 "os"26)27func pixelLoad(img image.Image) [][]int {28 b := img.Bounds()29 pix := [][]int{}30 for y := b.Min.Y; y < b.Max.Y; y++ {31 row := []int{}32 for x := b.Min.X; x < b.Max.X; x++ {33 r, g, b, a := img.At(x, y).RGBA()34 if r == 65535 && g == 65278 && b == 57311 && a == 65535 {35 row = append(row, 0)36 } else {37 row = append(row, 1)38 }39 }40 pix = append(pix, row)41 }42 return pix43}44func match_img(rx, ry int, pix1 [][]int, mask1 [][]string) int {45 flag := 146 breakflag := 047 yy := len(mask1)48 count := 049 for y := 0; y < yy; y++ {50 for x := 0; x < len(mask1[y]); x++ {51 if ry+y < 24 && rx+x < 129 {52 if mask1[y][x] == "1" {53 if pix1[ry+y][rx+x] == 1 {54 count = count + 155 } else {56 flag = 057 breakflag = 158 break59 }60 }61 } else {62 flag = 063 breakflag = 164 break65 }66 }67 if breakflag == 1 {68 break69 }70 }71 if count == 0 {72 flag = 073 }74 return flag75}76func skip(start, end []int, y int) int {77 flag := 078 for i := 0; i < len(start); i++ {79 if y >= start[i] && y <= end[i] {80 flag = 181 break82 }83 }84 return flag85}86func sort(sorter []int, captcha []string) {87 for i := 0; i < len(sorter); i++ {88 less := sorter[i]89 swap := 090 ls := i91 for k := i; k < len(sorter); k++ {92 if sorter[k] < less {93 less = sorter[k]94 ls = k95 swap = 196 }97 }98 if swap == 1 {99 sorter[i], sorter[ls] = sorter[ls], sorter[i]100 captcha[i], captcha[ls] = captcha[ls], captcha[i]101 }102 }103}104func GetCaptcha(file *os.File) string {105 keys := map[string][][]string{106 "0": [][]string{107 []string{"0", "0", "0", "1", "1", "1", "1", "0", "0", "0"},108 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "0"},109 []string{"0", "1", "1", "1", "0", "0", "0", "1", "1", "0"},110 []string{"1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},111 []string{"1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},112 []string{"1", "1", "0", "0", "0", "1", "1", "0", "1", "1"},113 []string{"1", "1", "0", "0", "1", "1", "0", "0", "1", "1"},114 []string{"1", "1", "0", "1", "1", "0", "0", "0", "1", "1"},115 []string{"1", "1", "1", "1", "0", "0", "0", "0", "1", "1"},116 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1"},117 []string{"0", "1", "1", "0", "0", "0", "1", "1", "1", "0"},118 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "0"},119 []string{"0", "0", "0", "1", "1", "1", "1", "0", "0", "0"},120 },121 "1": [][]string{122 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},123 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},124 []string{"1", "1", "1", "1", "1", "1", "0", "0", "0"},125 []string{"1", "1", "1", "1", "1", "1", "0", "0", "0"},126 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},127 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},128 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},129 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},130 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},131 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},132 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0"},133 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},134 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},135 },136 "2": [][]string{137 []string{"0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},138 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},139 []string{"1", "1", "0", "0", "0", "1", "1", "1", "1", "0"},140 []string{"1", "0", "0", "0", "0", "0", "1", "1", "1", "0"},141 []string{"0", "0", "0", "0", "0", "0", "1", "1", "1", "0"},142 []string{"0", "0", "0", "0", "0", "0", "1", "1", "1", "0"},143 []string{"0", "0", "0", "0", "0", "1", "1", "1", "0", "0"},144 []string{"0", "0", "0", "0", "1", "1", "1", "1", "0", "0"},145 []string{"0", "0", "0", "1", "1", "1", "1", "0", "0", "0"},146 []string{"0", "0", "1", "1", "1", "1", "0", "0", "0", "0"},147 []string{"0", "1", "1", "1", "1", "0", "0", "0", "0", "0"},148 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},149 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},150 },151 "3": [][]string{152 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},153 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},154 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},155 []string{"1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},156 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "0"},157 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0"},158 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "1", "0"},159 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "1"},160 []string{"0", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},161 []string{"1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},162 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},163 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},164 []string{"0", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},165 },166 "4": [][]string{[]string{"0", "0", "0", "0", "0", "0", "1", "1", "1", "1", "0", "0"},167 []string{"0", "0", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0"},168 []string{"0", "0", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0"},169 []string{"0", "0", "0", "0", "1", "1", "0", "1", "1", "1", "0", "0"},170 []string{"0", "0", "0", "1", "1", "1", "0", "1", "1", "1", "0", "0"},171 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},172 []string{"0", "1", "1", "1", "0", "0", "0", "1", "1", "1", "0", "0"},173 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0", "0"},174 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},175 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},176 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "0", "0"},177 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "0", "0"},178 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "0", "0"},179 },180 "5": [][]string{[]string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},181 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},182 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0"},183 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0"},184 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},185 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},186 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "1"},187 []string{"0", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},188 []string{"0", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},189 []string{"1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},190 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},191 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},192 []string{"0", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"}}, "6": [][]string{[]string{"0", "0", "0", "0", "1", "1", "1", "1", "1", "1", "0"},193 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "0"},194 []string{"0", "1", "1", "1", "1", "0", "0", "0", "0", "0", "0"},195 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0"},196 []string{"1", "1", "1", "0", "1", "1", "1", "1", "1", "0", "0"},197 []string{"1", "1", "1", "0", "1", "1", "1", "1", "1", "1", "0"},198 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},199 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},200 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},201 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},202 []string{"0", "1", "1", "1", "0", "0", "0", "1", "1", "1", "0"},203 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},204 []string{"0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0"}}, "7": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},205 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},206 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "1"},207 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "0"},208 []string{"0", "0", "0", "0", "0", "0", "1", "1", "1", "1", "0"},209 []string{"0", "0", "0", "0", "0", "0", "1", "1", "1", "0", "0"},210 []string{"0", "0", "0", "0", "0", "1", "1", "1", "0", "0", "0"},211 []string{"0", "0", "0", "0", "1", "1", "1", "1", "0", "0", "0"},212 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},213 []string{"0", "0", "0", "1", "1", "1", "1", "0", "0", "0", "0"},214 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0", "0", "0"},215 []string{"0", "0", "1", "1", "1", "0", "0", "0", "0", "0", "0"},216 []string{"0", "0", "1", "1", "1", "0", "0", "0", "0", "0", "0"}}, "8": [][]string{[]string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "0", "0"},217 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},218 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},219 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},220 []string{"1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "0"},221 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},222 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "0", "0"},223 []string{"0", "1", "1", "1", "0", "1", "1", "1", "1", "1", "0"},224 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},225 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},226 []string{"1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1"},227 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},228 []string{"0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"}}, "9": [][]string{[]string{"0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0"},229 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},230 []string{"0", "1", "1", "1", "0", "0", "0", "1", "1", "1", "0"},231 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},232 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},233 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},234 []string{"1", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},235 []string{"0", "1", "1", "1", "1", "1", "1", "0", "1", "1", "1"},236 []string{"0", "0", "1", "1", "1", "1", "1", "0", "1", "1", "1"},237 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "0"},238 []string{"0", "0", "0", "0", "0", "0", "1", "1", "1", "1", "0"},239 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},240 []string{"0", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0"}}, "A": [][]string{[]string{"0", "0", "0", "0", "1", "1", "1", "1", "0", "0", "0", "0"},241 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},242 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},243 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},244 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},245 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},246 []string{"0", "1", "1", "1", "1", "0", "0", "1", "1", "1", "1", "0"},247 []string{"0", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},248 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},249 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},250 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},251 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},252 []string{"1", "1", "0", "0", "0", "0", "0", "0", "0", "0", "1", "1"}}, "B": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},253 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},254 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},255 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},256 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},257 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},258 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},259 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},260 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},261 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},262 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},263 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},264 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"}}, "C": [][]string{[]string{"0", "0", "0", "0", "1", "1", "1", "1", "1", "1", "0"},265 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1"},266 []string{"0", "1", "1", "1", "1", "0", "0", "0", "0", "1", "1"},267 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "1"},268 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0"},269 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0"},270 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0"},271 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0"},272 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0"},273 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "1"},274 []string{"0", "1", "1", "1", "1", "0", "0", "0", "0", "1", "1"},275 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1"},276 []string{"0", "0", "0", "0", "1", "1", "1", "1", "1", "1", "0"}}, "D": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0"},277 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},278 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "0"},279 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "0"},280 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},281 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},282 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},283 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},284 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},285 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "0"},286 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "0"},287 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},288 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0"}}, "E": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},289 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},290 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},291 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},292 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},293 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0"},294 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0"},295 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},296 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},297 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},298 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},299 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},300 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"}}, "F": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},301 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},302 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},303 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},304 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},305 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},306 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},307 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},308 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},309 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},310 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},311 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},312 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"}}, "G": [][]string{[]string{"0", "0", "0", "0", "1", "1", "1", "1", "1", "1", "1", "0", "0"},313 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},314 []string{"0", "1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},315 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0", "1"},316 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"},317 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"},318 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "1", "1"},319 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "1", "1"},320 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},321 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},322 []string{"0", "1", "1", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},323 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},324 []string{"0", "0", "0", "0", "1", "1", "1", "1", "1", "1", "1", "0", "0"}}, "H": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},325 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},326 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},327 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},328 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},329 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},330 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},331 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},332 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},333 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},334 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},335 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},336 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"}}, "I": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1"},337 []string{"1", "1", "1", "1", "1", "1", "1"},338 []string{"0", "0", "1", "1", "1", "0", "0"},339 []string{"0", "0", "1", "1", "1", "0", "0"},340 []string{"0", "0", "1", "1", "1", "0", "0"},341 []string{"0", "0", "1", "1", "1", "0", "0"},342 []string{"0", "0", "1", "1", "1", "0", "0"},343 []string{"0", "0", "1", "1", "1", "0", "0"},344 []string{"0", "0", "1", "1", "1", "0", "0"},345 []string{"0", "0", "1", "1", "1", "0", "0"},346 []string{"0", "0", "1", "1", "1", "0", "0"},347 []string{"1", "1", "1", "1", "1", "1", "1"},348 []string{"1", "1", "1", "1", "1", "1", "1"}}, "J": [][]string{[]string{"0", "0", "1", "1", "1", "1", "1", "1"},349 []string{"0", "0", "1", "1", "1", "1", "1", "1"},350 []string{"0", "0", "0", "0", "0", "1", "1", "1"},351 []string{"0", "0", "0", "0", "0", "1", "1", "1"},352 []string{"0", "0", "0", "0", "0", "1", "1", "1"},353 []string{"0", "0", "0", "0", "0", "1", "1", "1"},354 []string{"0", "0", "0", "0", "0", "1", "1", "1"},355 []string{"0", "0", "0", "0", "0", "1", "1", "1"},356 []string{"0", "0", "0", "0", "0", "1", "1", "1"},357 []string{"0", "0", "0", "0", "0", "1", "1", "1"},358 []string{"0", "0", "0", "0", "1", "1", "1", "1"},359 []string{"1", "1", "1", "1", "1", "1", "1", "0"},360 []string{"1", "1", "1", "1", "1", "1", "0", "0"}}, "K": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},361 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},362 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "0"},363 []string{"1", "1", "1", "0", "0", "1", "1", "1", "1", "0", "0"},364 []string{"1", "1", "1", "0", "0", "1", "1", "1", "0", "0", "0"},365 []string{"1", "1", "1", "0", "1", "1", "1", "0", "0", "0", "0"},366 []string{"1", "1", "1", "1", "1", "1", "1", "0", "0", "0", "0"},367 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},368 []string{"1", "1", "1", "0", "0", "1", "1", "1", "0", "0", "0"},369 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "0", "0"},370 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},371 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},372 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"}}, "L": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},373 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},374 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},375 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},376 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},377 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},378 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},379 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},380 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},381 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},382 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0"},383 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"},384 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1"}}, "M": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},385 []string{"1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "1"},386 []string{"1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "1"},387 []string{"1", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "1"},388 []string{"1", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "1"},389 []string{"1", "1", "1", "1", "1", "1", "0", "1", "1", "1", "1", "1", "1"},390 []string{"1", "1", "1", "0", "1", "1", "0", "1", "1", "0", "1", "1", "1"},391 []string{"1", "1", "1", "0", "1", "1", "1", "1", "1", "0", "1", "1", "1"},392 []string{"1", "1", "1", "0", "0", "1", "1", "1", "0", "0", "1", "1", "1"},393 []string{"1", "1", "1", "0", "0", "1", "1", "1", "0", "0", "1", "1", "1"},394 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},395 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},396 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"}}, "N": [][]string{[]string{"1", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},397 []string{"1", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1"},398 []string{"1", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1"},399 []string{"1", "1", "1", "1", "1", "1", "0", "0", "1", "1", "1"},400 []string{"1", "1", "1", "1", "1", "1", "0", "0", "1", "1", "1"},401 []string{"1", "1", "1", "0", "1", "1", "1", "0", "1", "1", "1"},402 []string{"1", "1", "1", "0", "1", "1", "1", "0", "1", "1", "1"},403 []string{"1", "1", "1", "0", "0", "1", "1", "1", "1", "1", "1"},404 []string{"1", "1", "1", "0", "0", "1", "1", "1", "1", "1", "1"},405 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "1"},406 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "1"},407 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},408 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"}}, "O": [][]string{[]string{"0", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0", "0"},409 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},410 []string{"0", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "0"},411 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "0"},412 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},413 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},414 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},415 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},416 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},417 []string{"0", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "0"},418 []string{"0", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "0"},419 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},420 []string{"0", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0", "0"}}, "P": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},421 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},422 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "1"},423 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},424 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},425 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},426 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "1"},427 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},428 []string{"1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},429 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0"},430 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0"},431 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0"},432 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0"}}, "Q": [][]string{[]string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},433 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},434 []string{"0", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},435 []string{"0", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "0"},436 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "0", "1", "1"},437 []string{"1", "1", "0", "0", "0", "0", "0", "0", "0", "0", "1", "1"},438 []string{"1", "1", "0", "0", "0", "0", "0", "0", "0", "0", "1", "1"},439 []string{"1", "1", "0", "0", "0", "0", "0", "1", "0", "0", "1", "1"},440 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "0", "1", "1"},441 []string{"0", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "0"},442 []string{"0", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},443 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},444 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "1", "0"}}, "R": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},445 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},446 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},447 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},448 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},449 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "0"},450 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},451 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},452 []string{"1", "1", "1", "0", "0", "1", "1", "1", "1", "0", "0"},453 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "0", "0"},454 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},455 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},456 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"}}, "S": [][]string{[]string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0"},457 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},458 []string{"1", "1", "1", "1", "0", "0", "0", "0", "1", "1", "0"},459 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "0"},460 []string{"1", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0"},461 []string{"1", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"},462 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},463 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "1", "1"},464 []string{"0", "0", "0", "0", "0", "0", "0", "1", "1", "1", "1"},465 []string{"1", "0", "0", "0", "0", "0", "0", "0", "1", "1", "1"},466 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},467 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},468 []string{"0", "1", "1", "1", "1", "1", "1", "1", "0", "0", "0"}}, "T": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},469 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},470 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},471 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},472 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},473 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},474 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},475 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},476 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},477 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},478 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},479 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},480 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"}}, "U": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},481 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},482 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},483 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},484 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},485 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},486 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},487 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},488 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},489 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},490 []string{"1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1"},491 []string{"0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "0"},492 []string{"0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0"}}, "V": [][]string{[]string{"1", "1", "0", "0", "0", "0", "0", "0", "0", "0", "1", "1"},493 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},494 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},495 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "1"},496 []string{"0", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},497 []string{"0", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0"},498 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},499 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},500 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},501 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},502 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},503 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},504 []string{"0", "0", "0", "0", "1", "1", "1", "1", "0", "0", "0", "0"}}, "W": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},505 []string{"1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1"},506 []string{"1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1"},507 []string{"0", "1", "1", "1", "0", "0", "1", "1", "0", "1", "1", "0", "0", "1", "1", "1", "0"},508 []string{"0", "1", "1", "1", "0", "0", "1", "1", "0", "1", "1", "0", "0", "1", "1", "1", "0"},509 []string{"0", "1", "1", "1", "0", "1", "1", "1", "0", "1", "1", "1", "0", "1", "1", "1", "0"},510 []string{"0", "1", "1", "1", "0", "1", "1", "1", "0", "1", "1", "1", "0", "1", "1", "1", "0"},511 []string{"0", "1", "1", "1", "0", "1", "1", "0", "0", "0", "1", "1", "0", "1", "1", "1", "0"},512 []string{"0", "1", "1", "1", "0", "1", "1", "0", "0", "0", "1", "1", "0", "1", "1", "1", "0"},513 []string{"0", "0", "1", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0"},514 []string{"0", "0", "1", "1", "1", "1", "1", "0", "0", "0", "1", "1", "1", "1", "1", "0", "0"},515 []string{"0", "0", "1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "1", "0", "0"},516 []string{"0", "0", "1", "1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1", "1", "0", "0"}}, "X": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"},517 []string{"1", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},518 []string{"0", "1", "1", "1", "1", "0", "0", "1", "1", "1", "1", "0"},519 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},520 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},521 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},522 []string{"0", "0", "0", "0", "1", "1", "1", "1", "0", "0", "0", "0"},523 []string{"0", "0", "0", "1", "1", "1", "1", "1", "1", "0", "0", "0"},524 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "0", "0"},525 []string{"0", "0", "1", "1", "1", "0", "0", "1", "1", "1", "0", "0"},526 []string{"0", "1", "1", "1", "1", "0", "0", "1", "1", "1", "1", "0"},527 []string{"1", "1", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1"},528 []string{"1", "1", "1", "0", "0", "0", "0", "0", "0", "1", "1", "1"}}, "Y": [][]string{[]string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},529 []string{"1", "1", "1", "0", "0", "0", "0", "0", "1", "1", "1"},530 []string{"0", "1", "1", "1", "0", "0", "0", "1", "1", "1", "0"},531 []string{"0", "1", "1", "1", "1", "0", "1", "1", "1", "1", "0"},532 []string{"0", "0", "1", "1", "1", "0", "1", "1", "1", "0", "0"},533 []string{"0", "0", "1", "1", "1", "1", "1", "1", "1", "0", "0"},534 []string{"0", "0", "0", "1", "1", "1", "1", "1", "0", "0", "0"},535 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},536 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},537 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},538 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},539 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},540 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "0"}}, "Z": [][]string{[]string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},541 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},542 []string{"0", "0", "0", "0", "0", "0", "1", "1", "1", "1"},543 []string{"0", "0", "0", "0", "0", "1", "1", "1", "1", "0"},544 []string{"0", "0", "0", "0", "0", "1", "1", "1", "0", "0"},545 []string{"0", "0", "0", "0", "1", "1", "1", "0", "0", "0"},546 []string{"0", "0", "0", "1", "1", "1", "1", "0", "0", "0"},547 []string{"0", "0", "0", "1", "1", "1", "0", "0", "0", "0"},548 []string{"0", "0", "1", "1", "1", "0", "0", "0", "0", "0"},549 []string{"0", "1", "1", "1", "1", "0", "0", "0", "0", "0"},550 []string{"1", "1", "1", "1", "0", "0", "0", "0", "0", "0"},551 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},552 []string{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"}},553 }554 order := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}555 img, _ := bmp.Decode(file)556 pix := pixelLoad(img)557 newpix := [][]int{}558 for y := 0; y < 24; y++ {559 t := []int{}560 for x := 0; x < 129; x++ {561 temp := pix[y][x]562 if y != 0 && y != 24 {563 if pix[y+1][x] == 0 && temp == 1 && pix[y-1][x] == 0 {564 pix[y][x] = 0565 }566 }567 t = append(t, pix[y][x])568 }569 newpix = append(newpix, t)570 }571 xoff := 20572 yoff := 2573 skipstart := []int{}574 skipend := []int{}575 sorter := []int{}576 captcha := []string{}577 for l := 0; l < 36; l++ {578 mask := keys[order[l]]579 f := 0580 for y := yoff; y < 24; y++ {581 for x := xoff; x < 129; x++ {582 if skip(skipstart, skipend, x) == 0 {583 if match_img(x, y, newpix, mask) != 0 {584 skipstart = append(skipstart, x)585 skipend = append(skipend, x+len(mask[0]))586 sorter = append(sorter, x)587 captcha = append(captcha, order[l])588 f = f + 1589 }590 }591 }592 }593 if f == 6 {594 break595 }596 }597 sort(sorter, captcha)598 result := ""599 for cap := range captcha {600 result = result + captcha[cap]601 }602 return result603}...

Full Screen

Full Screen

task.go

Source:task.go Github

copy

Full Screen

1package task2import (3 "context"4 "fmt"5 "sort"6 "time"7 "github.com/go-co-op/gocron"8 log "github.com/sirupsen/logrus"9 "github.com/spf13/viper"10)11// Task interface declares the methods that a Task subtype should implement.12type Task interface {13 Run(context.Context) error14 GetPriority() uint15 GetRate() interface{}16 GetTTL() time.Duration17 SkipStartup() bool18}19// WrapTimeout wraps the `Run` interface method with a timeout-dependent context.20func WrapTimeout(t Task, noLog bool) error {21 var err error22 // Create context without timeout equal to given time-to-live.23 ctx, cancel := context.WithTimeout(context.Background(), t.GetTTL())24 defer cancel()25 taskTermination := make(chan bool, 1)26 go func() {27 err = t.Run(ctx)28 taskTermination <- true29 }()30 select {31 case <-ctx.Done():32 return ctx.Err()33 case <-taskTermination:34 if err != nil {35 if !noLog {36 log.Error(err)37 }38 return err39 }40 }41 return nil42}43type priorityToTaskMap map[uint][]Task44// DailyTask is a Task that is run every day.45type DailyTask struct {46 TimeOfDay string47 Priority uint48 TTL time.Duration49 SkipStart bool50 RunFunc func(context.Context) error51}52// Run wraps the internal RunFunc field. This method runs it and returns the result.53func (d DailyTask) Run(ctx context.Context) error {54 return d.RunFunc(ctx)55}56// GetPriority returns the task priority.57func (d DailyTask) GetPriority() uint {58 return d.Priority59}60// GetRate returns the repeat frequency for the task.61func (d DailyTask) GetRate() interface{} {62 return d.TimeOfDay63}64// GetTTL returns the maximum duration of the task. This parameter is to prevent the task65// from running too long if it hangs.66func (d DailyTask) GetTTL() time.Duration {67 return d.TTL68}69// SkipStartup returns whether or not the task should be skipped during the initial startup phase.70func (d DailyTask) SkipStartup() bool {71 return d.SkipStart72}73// MinuteTask is a Task that is run every n minutes where Rate defines74// how often the task is run.75type MinuteTask struct {76 Rate uint6477 Priority uint78 TTL time.Duration79 SkipStart bool80 RunFunc func(context.Context) error81}82// Run wraps the internal RunFunc field. This method runs it and returns the result.83func (m MinuteTask) Run(ctx context.Context) error {84 return m.RunFunc(ctx)85}86// GetPriority returns the task priority.87func (m MinuteTask) GetPriority() uint {88 return m.Priority89}90// GetRate returns the repeat frequency for the task.91func (m MinuteTask) GetRate() interface{} {92 return m.Rate93}94// GetTTL returns the maximum duration of the task. This parameter is to prevent the task95// from running too long if it hangs.96func (m MinuteTask) GetTTL() time.Duration {97 return m.TTL98}99// SkipStartup returns whether or not the task should be skipped during the initial startup phase.100func (m MinuteTask) SkipStartup() bool {101 return m.SkipStart102}103// Runner is the main background task runner in this package.104type Runner struct {105 scheduler *gocron.Scheduler106 tasks []Task107}108// NewRunner initializes a new Runner struct.109func NewRunner() (*Runner, error) {110 location, err := time.LoadLocation(viper.GetString("timezone"))111 if err != nil {112 return &Runner{}, err113 }114 scheduler := gocron.NewScheduler(location)115 tasks := make([]Task, 0, 5)116 return &Runner{117 scheduler: scheduler,118 tasks: tasks,119 }, nil120}121// AddTask adds the task to the runner and schedules it.122func (r *Runner) AddTask(task Task) error {123 switch t := task.(type) {124 case DailyTask:125 r.scheduler.Every(1).Day().At(task.GetRate().(string)).Do(WrapTimeout, task, false)126 case MinuteTask:127 r.scheduler.Every(task.GetRate().(uint64)).Minutes().Do(WrapTimeout, task, false)128 default:129 return fmt.Errorf(`No scheduler for type %T`, t)130 }131 r.tasks = append(r.tasks, task)132 return nil133}134func (r *Runner) exposePriorities() priorityToTaskMap {135 taskMap := make(priorityToTaskMap, len(r.tasks))136 for _, task := range r.tasks {137 priority := task.GetPriority()138 taskMap[priority] = append(taskMap[priority], task)139 }140 return taskMap141}142func (r *Runner) runAllTasksInOrder() error {143 exposedPriorities := r.exposePriorities()144 orderedPriorities := make([]uint, len(exposedPriorities))145 for priority := range exposedPriorities {146 orderedPriorities = append(orderedPriorities, priority)147 }148 sort.Slice(orderedPriorities, func(i, j int) bool {149 return orderedPriorities[i] < orderedPriorities[j]150 })151 for _, priority := range orderedPriorities {152 for _, task := range exposedPriorities[priority] {153 if !task.SkipStartup() {154 if err := WrapTimeout(task, true); err != nil {155 return err156 }157 }158 }159 }160 return nil161}162// Start runs all tasks in descending order of priority (where 0 is the highest priority)163// or by insertion order if two tasks have the same priority. Then it starts a background164// thread which will run all tasks every day at the specified time.165func (r *Runner) Start() error {166 if err := r.runAllTasksInOrder(); err != nil {167 return fmt.Errorf(`task failed during startup: %s`, err)168 }169 r.scheduler.StartAsync()170 return nil171}172// Stop stops the background thread.173func (r *Runner) Stop() {174 r.scheduler.Stop()175}...

Full Screen

Full Screen

decenarch.go

Source:decenarch.go Github

copy

Full Screen

1package main2import (3 "os"4 "path"5 "strings"6 "encoding/base64"7 urlpkg "net/url"8 decenarch "github.com/dedis/student_17_decenar"9 "gopkg.in/dedis/onet.v1/app"10 "gopkg.in/dedis/onet.v1/log"11 "gopkg.in/urfave/cli.v1"12)13// path to the directory where website will be stored for consultation14const cachePath = "/tmp/cocache"15func main() {16 log.Info("Start decenarch application")17 cliApp := cli.NewApp()18 cliApp.Name = "decenarch"19 cliApp.Usage = "retrieve static websites"20 cliApp.Version = "0.1"21 groupsDef := "the group-definition-file"22 cliApp.Commands = []cli.Command{23 {24 Name: "retrieve",25 Usage: "retrive the website",26 Aliases: []string{"r"},27 ArgsUsage: groupsDef,28 Action: cmdRetrieve,29 Flags: []cli.Flag{30 cli.StringFlag{31 Name: "url, u",32 Usage: "Provide url to retrieve",33 },34 cli.StringFlag{35 Name: "timestamp, t",36 Usage: "Provide timestamp",37 },38 },39 },40 {41 Name: "save",42 Usage: "save the website",43 Aliases: []string{"s"},44 ArgsUsage: groupsDef,45 Action: cmdSave,46 Flags: []cli.Flag{47 cli.StringFlag{48 Name: "url, u",49 Usage: "Provide url to save",50 },51 },52 },53 {54 Name: "skipstart",55 Usage: "start the storing skipchain",56 Aliases: []string{"k"},57 ArgsUsage: groupsDef,58 Action: cmdSkipStart,59 },60 }61 cliApp.Flags = []cli.Flag{62 app.FlagDebug,63 }64 cliApp.Before = func(c *cli.Context) error {65 log.SetDebugVisible(c.Int("debug"))66 return nil67 }68 cliApp.Run(os.Args)69}70// Returns the asked website if saved.71func cmdRetrieve(c *cli.Context) error {72 log.Info("Retrieve command")73 url := c.String("url")74 timestamp := c.String("timestamp")75 if url == "" {76 log.Fatal("Please provide an url with save -u [url] ")77 }78 if timestamp == "" {79 log.Info("It is possible to provide a timestamp with -t [2006/01/02 15:04]")80 }81 group := readGroup(c)82 client := decenarch.NewClient()83 resp, err := client.Retrieve(group.Roster, url, timestamp)84 if err != nil {85 log.Fatal("When asking to retrieve", url, ":", err)86 }87 // save data on local filesystem88 bPage, bErr := base64.StdEncoding.DecodeString(resp.Main.Page)89 if bErr != nil {90 return bErr91 }92 p, pErr := storeWebPageOnDisk(resp.Main.Url, bPage)93 if pErr != nil {94 return pErr95 }96 log.Info("Website", url, "stored in", p)97 for _, adds := range resp.Adds {98 abPage, abErr := base64.StdEncoding.DecodeString(adds.Page)99 if abErr == nil {100 log.Info("Storing", adds.Url)101 _, apErr := storeWebPageOnDisk(adds.Url, abPage)102 if apErr != nil {103 log.Lvl1("An non-fatal error occured:", apErr)104 }105 } else {106 log.Lvl1("An non-fatal error occured:", abErr)107 }108 }109 log.Info("Website sucessfully stored in", p)110 return nil111}112// Saves the asked website and returns an exit state113func cmdSave(c *cli.Context) error {114 log.Info("Save command")115 url := c.String("url")116 if url == "" {117 log.Fatal("Please provide an url.")118 }119 group := readGroup(c)120 client := decenarch.NewClient()121 resp, err := client.Save(group.Roster, url)122 if err != nil {123 log.Fatal("When asking to save", url, ":", err)124 }125 log.Info("Website", url, "saved.", resp)126 return nil127}128// Start the skipchain that will be responsible to store the websites archived129func cmdSkipStart(c *cli.Context) error {130 log.Info("SkipStart command")131 group := readGroup(c)132 client := decenarch.NewSkipClient()133 resp, err := client.SkipStart(group.Roster)134 if err != nil {135 log.Fatal("When asking to start skipchain", err)136 }137 log.Info("Skipchain started with", resp)138 return nil139}140func readGroup(c *cli.Context) *app.Group {141 if c.NArg() != 1 {142 log.Fatal("Please give the group-file as argument")143 }144 name := c.Args().First()145 f, err := os.Open(name)146 log.ErrFatal(err, "Couldn't open group definition file")147 group, err := app.ReadGroupDescToml(f)148 log.ErrFatal(err, "Error while reading group definition file", err)149 if len(group.Roster.List) == 0 {150 log.ErrFatalf(err, "Empty entity or invalid group defintion in: %s",151 name)152 }153 return group154}155// storeWebPageOnDisk store the data bData on the filesystem under the path:156// $cachePath/<path infer from url>.157// Example: url==http://my.example.ext/folder/file.fext will be stored in158// $cachePath/ext/example/my/folder/file.fext and file.fext will contains bData159func storeWebPageOnDisk(mUrl string, bData []byte) (string, error) {160 pUrl, puErr := urlpkg.Parse(mUrl)161 if puErr != nil {162 return "", puErr163 }164 var urlDir string165 for _, dom := range strings.Split(pUrl.Host, ".") {166 urlDir = dom + "/" + urlDir167 }168 locDir, locFile := path.Split(pUrl.Path)169 if locFile == "" {170 locFile = "index.html"171 }172 mkErr := os.MkdirAll(path.Join(cachePath, urlDir, locDir), os.ModePerm|os.ModeDir)173 if mkErr != nil {174 return "", mkErr175 }176 mainFile, mfErr := os.Create(path.Join(cachePath, urlDir, locDir, locFile))177 if mfErr != nil {178 return "", mfErr179 }180 _, writErr := mainFile.Write(bData)181 if writErr != nil {182 return "", writErr183 }184 return path.Join(cachePath, urlDir, locDir, locFile), nil185}...

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("main")4 skipStart()5}6import (7func main() {8 fmt.Println("main")9 skipStart()10}11import (12func main() {13 fmt.Println("main")14 skipStart()15}16import (17func main() {18 fmt.Println("main")19 skipStart()20}21import (22func main() {23 fmt.Println("main")24 skipStart()25}26import (27func main() {28 fmt.Println("main")29 skipStart()30}31import (32func main() {33 fmt.Println("main")34 skipStart()35}36import (37func main() {38 fmt.Println("main")39 skipStart()40}41import (42func main() {43 fmt.Println("main")44 skipStart()45}46import (47func main() {48 fmt.Println("main")49 skipStart()50}51import (52func main() {53 fmt.Println("main")54 skipStart()55}56import (57func main() {58 fmt.Println("main")59 skipStart()60}61import (

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("I am in main")4 skipStart()5}6import "fmt"7func skipStart() {8 fmt.Println("I am in skipStart")9}10import "fmt"11func skipStart() {12 fmt.Println("I am in skipStart")13}14import "fmt"15func skipStart() {16 fmt.Println("I am in skipStart")17}18import "fmt"19func skipStart() {20 fmt.Println("I am in skipStart")21}22import "fmt"23func skipStart() {24 fmt.Println("I am in skipStart")25}26import "fmt"27func skipStart() {28 fmt.Println("I am in skipStart")29}30import "fmt"31func skipStart() {32 fmt.Println("I am in skipStart")33}34import "fmt"35func skipStart() {36 fmt.Println("I am in skipStart")37}38import "fmt"39func skipStart() {40 fmt.Println("I am in skipStart")41}42import "fmt"43func skipStart() {44 fmt.Println("I am in skipStart")45}46import "fmt"47func skipStart() {48 fmt.Println("I am in skipStart")49}50import

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(f.Abs())4 fmt.Println(Abs(f))5 fmt.Println(Abs(x))6 fmt.Println(Abs(y))7}8import (9func (f MyFloat) Abs() float64 {10 if f < 0 {11 return float64(-f)12 }13 return float64(f)14}15func Abs(f MyFloat) float64 {16 if f < 0 {17 return float64(-f)18 }19 return float64(f)20}21func main() {22 fmt.Println(f.Abs())23 fmt.Println(Abs(f))24 fmt.Println(Abs(x))25 fmt.Println(Abs(y))26}27import (28func (f MyFloat) Abs() float64 {29 if f < 0 {30 return float64(-f)31 }32 return float64(f)33}34func Abs(f float64) float64 {35 if f < 0 {36 return float64(-f)37 }38 return float64(f)39}40func main() {41 fmt.Println(f.Abs())42 fmt.Println(Abs(f))43 fmt.Println(Abs(x))44 fmt.Println(Abs(y))45}46import (47func (f MyFloat) Abs() float64 {48 if f < 0 {49 return float64(-f)50 }51 return float64(f)52}53func Abs(f MyFloat) float64 {54 if f < 0 {55 return float64(-f)56 }57 return float64(f)58}59func main() {60 fmt.Println(f.Abs())61 fmt.Println(Abs(f))

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, playground")4 skipStart()5}6import "fmt"7func main() {8 fmt.Println("Hello, playground")9 skipStart()10}11import "fmt"12func main() {13 fmt.Println("Hello, playground")14 skipStart()15}16import "fmt"17func main() {18 fmt.Println("Hello, playground")19 skipStart()20}21import "fmt"22func main() {23 fmt.Println("Hello, playground")24 skipStart()25}26import "fmt"27func main() {28 fmt.Println("Hello, playground")29 skipStart()30}31import "fmt"32func main() {33 fmt.Println("Hello, playground")34 skipStart()35}36import "fmt"37func main() {38 fmt.Println("Hello, playground")39 skipStart()40}41import "fmt"42func main() {43 fmt.Println("Hello, playground")44 skipStart()45}46import "fmt"47func main() {48 fmt.Println("Hello, playground")49 skipStart()50}51import "fmt"52func main() {53 fmt.Println("Hello, playground")54 skipStart()55}56import "fmt"57func main() {58 fmt.Println("Hello, playground")59 skipStart()60}

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Print("Enter a number: ")4 fmt.Scan(&number)5 skipStart(number)6}7import "fmt"8func main() {9 fmt.Print("Enter a number: ")10 fmt.Scan(&number)11 skipStart(number)12}13import "fmt"14func main() {15 fmt.Print("Enter a number: ")16 fmt.Scan(&number)17 skipStart(number)18}19import "fmt"20func main() {21 fmt.Print("Enter a number: ")22 fmt.Scan(&number)23 skipStart(number)24}25import "fmt"26func main() {27 fmt.Print("Enter a number: ")28 fmt.Scan(&number)29 skipStart(number)30}31import "fmt"32func main() {33 fmt.Print("Enter a number: ")34 fmt.Scan(&number)35 skipStart(number)36}37import "fmt"38func main() {39 fmt.Print("Enter a number: ")40 fmt.Scan(&number)41 skipStart(number)42}43import "fmt"44func main() {45 fmt.Print("Enter a number: ")46 fmt.Scan(&number)47 skipStart(number)48}49import "fmt"50func main() {51 fmt.Print("Enter a number: ")52 fmt.Scan(&number)53 skipStart(number)54}

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println(main.skipStart("Hello", 3))5}6import (7func main() {8 fmt.Println("Hello, playground")9 fmt.Println(main.skipStart("Hello", 3))10}11import (12func main() {13 fmt.Println("Hello, playground")14 fmt.Println(main.skipStart("Hello", 3))15}16import (17func main() {18 fmt.Println("Hello, playground")19 fmt.Println(main.skipStart("Hello", 3))20}21import (22func main() {23 fmt.Println("Hello, playground")24 fmt.Println(main.skipStart("Hello", 3))25}26import (27func main() {28 fmt.Println("Hello, playground")29 fmt.Println(main.skipStart("Hello", 3))30}31import (32func main() {33 fmt.Println("Hello, playground")34 fmt.Println(main.skipStart("Hello", 3))35}36import (37func main() {38 fmt.Println("Hello, playground")39 fmt.Println(main.skipStart("Hello", 3))40}41import (42func main() {43 fmt.Println("Hello, playground")44 fmt.Println(main.skipStart("Hello", 3))45}46import (

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("SkipStart method of main class")4 fmt.Println("-------------------------------")5 fmt.Println("")6 err := filepath.Walk(path, skipStart(pattern))7 if err != nil {8 fmt.Println("Error:", err)9 os.Exit(1)10 }11}12import (13func main() {14 fmt.Println("SkipStart method of main class")15 fmt.Println("-------------------------------")16 fmt.Println("")17 err := filepath.Walk(path, skipStart(pattern))18 if err != nil {19 fmt.Println("Error:", err)20 os.Exit(1)21 }22}23import (24func main() {25 fmt.Println("SkipStart method of main class")26 fmt.Println("-------------------------------")27 fmt.Println("")28 err := filepath.Walk(path, skipStart(pattern))29 if err != nil {30 fmt.Println("Error:", err)31 os.Exit(1)32 }33}34import (35func main() {36 fmt.Println("SkipStart method of main class")37 fmt.Println("-------------------------------")38 fmt.Println("")

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import (2func (c *main) skipStart() {3}4import (5func (c *main) skipStart() {6}7import (8func (c *main) skipStart() {9}10import (11func (c *main) skipStart() {12}13import (14func (c *main) skipStart() {15}16import (17func (c *main) skipStart() {18}19import (20func (c *main) skipStart() {21}22import (23func (c *main) skipStart() {24}25import (26func (c *main) skipStart() {27}28import (29func (c *main) skipStart() {30}

Full Screen

Full Screen

skipStart

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 main := new(main)4 fmt.Println(reflect.TypeOf(main).MethodByName("skipStart"))5}6import (7func main() {8 main := new(main)9 fmt.Println(reflect.TypeOf(main).MethodByName("skipStart").Func.Call([]reflect.Value{}))10}11import (12func main() {13 main := new(main)14 fmt.Println(reflect.TypeOf(main).MethodByName("skipStart").Func.Call([]reflect.Value{reflect.ValueOf(main)}))15}16import (17func main() {18 main := new(main)19 fmt.Println(reflect.TypeOf(main).MethodByName("skipStart").Func.Call([]reflect.Value{reflect.ValueOf(main)})[0].Interface())20}21import (22func main() {23 main := new(main)24 fmt.Println(reflect.TypeOf(main).MethodByName("skipStart").Func.Call([]reflect.Value{reflect.ValueOf(main)})[0].Interface().(main))25}26import (27func main() {28 main := new(main)29 fmt.Println(reflect.TypeOf(main).MethodByName("skipStart").Func.Call([]reflect.Value{reflect.ValueOf(main)})[0].Interface().(*main))30}31import (32func main() {33 main := new(main)34 fmt.Println(reflect.TypeOf(main).MethodByName("skipStart").Func.Call([]reflect.Value{

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful