Skip to content

Commit 75cb834

Browse files
committed
Improvements
1 parent 059bd00 commit 75cb834

File tree

7 files changed

+42
-120
lines changed

7 files changed

+42
-120
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
sudo: false
2-
31
language: go
42

53
go:
@@ -23,7 +21,6 @@ matrix:
2321
- go: tip
2422

2523
before_install:
26-
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
2724
- make deps
2825
- make deps-test
2926

Gopkg.lock

Lines changed: 0 additions & 76 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

Makefile

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
11
################################################################################
22

3-
# This Makefile generated by GoMakeGen 1.0.0 using next command:
4-
# gomakegen --dep --verbose .
3+
# This Makefile generated by GoMakeGen 1.1.0 using next command:
4+
# gomakegen --verbose .
55
#
66
# More info: https://kaos.sh/gomakegen
77

88
################################################################################
99

1010
.DEFAULT_GOAL := help
11-
.PHONY = fmt git-config deps deps-test test dep-init dep-update help
11+
.PHONY = fmt git-config deps deps-test test help
1212

1313
################################################################################
1414

1515
git-config: ## Configure git redirects for stable import path services
1616
git config --global http.https://pkg.re.followRedirects true
1717

18-
deps: git-config dep-update ## Download dependencies
18+
deps: git-config ## Download dependencies
19+
go get -d -v github.com/valyala/fasthttp
1920

20-
deps-test: ## Download dependencies for tests
21-
git config --global http.https://pkg.re.followRedirects true
21+
deps-test: git-config ## Download dependencies for tests
2222
go get -d -v pkg.re/check.v1
2323

2424
test: ## Run tests
2525
go test -v -covermode=count .
2626

27-
dep-init: ## Initialize dep workspace
28-
which dep &>/dev/null || go get -u -v github.com/golang/dep/cmd/dep
29-
dep init
30-
31-
dep-update: ## Update packages and dependencies through dep
32-
which dep &>/dev/null || go get -u -v github.com/golang/dep/cmd/dep
33-
test -s Gopkg.toml || dep init
34-
dep ensure -update
35-
3627
fmt: ## Format source code with gofmt
3728
find . -name "*.go" -exec gofmt -s -w {} \;
3829

3930
help: ## Show this info
40-
@echo -e '\nSupported targets:\n'
31+
@echo -e '\n\033[1mSupported targets:\033[0m\n'
4132
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
4233
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}'
4334
@echo -e ''
35+
@echo -e '\033[90mGenerated by GoMakeGen 1.1.0\033[0m\n'
4436

4537
################################################################################

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
<p align="center"><a href="#readme"><img src="https://gh.kaos.st/sslscan.svg"/></a></p>
22

3-
<p align="center"><a href="#installation">Installation</a> • <a href="#build-status">Build Status</a> • <a href="#contributing">Contributing</a> • <a href="#terms-of-use">Terms of Use</a> • <a href="#license">License</a></p>
4-
53
<p align="center">
6-
<a href="https://godoc.org/pkg.re/essentialkaos/sslscan.v10"><img src="https://godoc.org/github.com/essentialkaos/sslscan?status.svg"></a>
4+
<a href="https://godoc.org/pkg.re/essentialkaos/sslscan.v11"><img src="https://godoc.org/github.com/essentialkaos/sslscan?status.svg"></a>
75
<a href="https://goreportcard.com/report/github.com/essentialkaos/sslscan"><img src="https://goreportcard.com/badge/github.com/essentialkaos/sslscan"></a>
86
<a href="https://codebeat.co/projects/github-com-essentialkaos-sslscan"><img src="https://codebeat.co/badges/59a17b0e-b974-425e-a442-b9bcc3ccf7c0"></a>
97
<a href="https://travis-ci.org/essentialkaos/sslscan"><img src="https://travis-ci.org/essentialkaos/sslscan.svg"></a>
108
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
119
</p>
1210

11+
<p align="center"><a href="#installation">Installation</a> • <a href="#build-status">Build Status</a> • <a href="#contributing">Contributing</a> • <a href="#terms-of-use">Terms of Use</a> • <a href="#license">License</a></p>
12+
13+
<br/>
14+
1315
Package for Go for working with [SSLLabs](https://www.ssllabs.com) public API.
1416

1517
### Installation
1618

1719
To build the SSLScan from scratch, make sure you have a working Go 1.9+ workspace ([instructions](https://golang.org/doc/install)), then:
1820

1921
```
20-
go get pkg.re/essentialkaos/sslscan.v10
22+
go get pkg.re/essentialkaos/sslscan.v11
2123
```
2224

2325
If you want update SSLScan package to latest stable release, do:
2426

2527
```
26-
go get -u pkg.re/essentialkaos/sslscan.v10
28+
go get -u pkg.re/essentialkaos/sslscan.v11
2729
```
2830

2931
### Build Status

sslscan.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const (
149149
)
150150

151151
// VERSION is current package version
152-
const VERSION = "10.2.1"
152+
const VERSION = "11.0.0"
153153

154154
// ////////////////////////////////////////////////////////////////////////////////// //
155155

@@ -170,6 +170,8 @@ type AnalyzeProgress struct {
170170
host string
171171
prevStatus string
172172

173+
maxAge int
174+
173175
api *API
174176
}
175177

@@ -544,7 +546,7 @@ func NewAPI(app, version string) (*API, error) {
544546

545547
// Analyze start check for host
546548
func (api *API) Analyze(host string, params AnalyzeParams) (*AnalyzeProgress, error) {
547-
progress := &AnalyzeProgress{host: host, api: api}
549+
progress := &AnalyzeProgress{host: host, api: api, maxAge: params.MaxAge}
548550
query := "host=" + host
549551
query += "&" + paramsToQuery(params)
550552

@@ -558,13 +560,21 @@ func (api *API) Analyze(host string, params AnalyzeParams) (*AnalyzeProgress, er
558560
}
559561

560562
// Info return short info
561-
func (ap *AnalyzeProgress) Info(detailed bool) (*AnalyzeInfo, error) {
563+
func (ap *AnalyzeProgress) Info(detailed, fromCache bool) (*AnalyzeInfo, error) {
562564
query := "host=" + ap.host
563565

564566
if detailed {
565567
query += "&all=on"
566568
}
567569

570+
if fromCache {
571+
query += "&fromCache=on"
572+
573+
if ap.maxAge > 0 {
574+
query += "&maxAge=" + fmt.Sprintf("%d", ap.maxAge)
575+
}
576+
}
577+
568578
info := &AnalyzeInfo{}
569579
err := ap.api.doRequest(API_URL_ANALYZE+"?"+query, info)
570580

@@ -578,11 +588,11 @@ func (ap *AnalyzeProgress) Info(detailed bool) (*AnalyzeInfo, error) {
578588
}
579589

580590
// GetEndpointInfo returns detailed endpoint info
581-
func (ap *AnalyzeProgress) GetEndpointInfo(ip string) (*EndpointInfo, error) {
591+
func (ap *AnalyzeProgress) GetEndpointInfo(ip string, fromCache bool) (*EndpointInfo, error) {
582592
var err error
583593

584594
if ap.prevStatus != STATUS_READY {
585-
_, err = ap.Info(false)
595+
_, err = ap.Info(false, false)
586596

587597
if err != nil {
588598
return nil, err
@@ -594,8 +604,16 @@ func (ap *AnalyzeProgress) GetEndpointInfo(ip string) (*EndpointInfo, error) {
594604
}
595605

596606
query := "host=" + ap.host + "&s=" + ip
597-
info := &EndpointInfo{}
598607

608+
if fromCache {
609+
query += "&fromCache=on"
610+
611+
if ap.maxAge > 0 {
612+
query += "&maxAge=" + fmt.Sprintf("%d", ap.maxAge)
613+
}
614+
}
615+
616+
info := &EndpointInfo{}
599617
err = ap.api.doRequest(API_URL_DETAILED+"?"+query, info)
600618

601619
if err != nil {

sslscan_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ func (s *SSLLabsSuite) TestAnalyze(c *check.C) {
5858

5959
var info *AnalyzeInfo
6060

61-
fmt.Printf("Progress: ")
61+
fmt.Printf("Progress: ")
6262

6363
for {
64-
info, err = progress.Info(false)
64+
info, err = progress.Info(false, true)
6565

6666
c.Assert(info, check.NotNil)
6767
c.Assert(err, check.IsNil)
@@ -98,7 +98,7 @@ func (s *SSLLabsSuite) TestAnalyze(c *check.C) {
9898
c.Assert(info.Endpoints[0].Delegation, check.Equals, 1)
9999
c.Assert(info.Endpoints[0].Details, check.IsNil)
100100

101-
fullInfo, err := progress.Info(true)
101+
fullInfo, err := progress.Info(true, true)
102102

103103
c.Assert(err, check.IsNil)
104104
c.Assert(fullInfo, check.NotNil)

0 commit comments

Comments
 (0)