etix / mirrorbits

Mirrorbits is a geographical download redirector written in Go for distributing files efficiently across a set of mirrors.
MIT License
497 stars 90 forks source link

using mirrorbits edit diff incorrect missing values #124

Open loanfedora opened 2 years ago

loanfedora commented 2 years ago

add test mirror

root@centos:~/mirrorbits# mirrorbits list
Identifier  STATE   SINCE
root@centos:~/mirrorbits# mirrorbits add -http http://localhost test
Warning: the hostname returned more than one address. Assuming they're sharing the same location.
Warning: unable to guess the geographic location of this mirror

Mirror 'test' added successfully
Enable this mirror using
  $ mirrorbits enable test
root@centos:~/mirrorbits# mirrorbits show test
Name: test
HttpURL: http://localhost/
RsyncURL: ""
FtpURL: ""
SponsorName: ""
SponsorURL: ""
SponsorLogoURL: ""
AdminName: ""
AdminEmail: ""
CustomData: ""
ContinentOnly: false
CountryOnly: false
ASOnly: false
Score: 0
Latitude: 0
Longitude: 0
ContinentCode: ""
CountryCodes: ""
ExcludedCountryCodes: ""
ASNum: 0
Enabled: false
AllowRedirects: null

Comment:

root@centos:~/mirrorbits# export EDITOR=vi
root@centos:~/mirrorbits# mirrorbits edit test

edit mirror

:%s/^Enabled: .*/Enabled: true
:%s/^CountryCodes: .*/CountryCodes: AF AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI CV KH CM CA KY CF TD CL CN CX CC CO KM CD CG CK CR HR CU CW CY CZ CI DK DJ DM DO EC EG SV GQ ER EE SZ ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM VA HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA MK RO RU RW RE BL SH KN LC MF PM VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK SD SR SJ SE CH SY TW TJ TZ TH TL TG TK TO TT TN TR TM TC TV UG UA AE GB UM US UY UZ VU VE VN VG VI WF EH YE ZM ZW AX
:wq

CountryCodes from https://www.iban.com/country-codes

after saving this happens

root@centos:~# mirrorbits edit test
- CountryCodes: ""
+ CountryCodes: AF AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ
- ExcludedCountryCodes: ""
+   BM BT BO BQ BA BW BV BR IO BN BG BF BI CV KH CM CA KY CF TD CL CN CX CC CO KM CD
- ASNum: 0
+   CG CK CR HR CU CW CY CZ CI DK DJ DM DO EC EG SV GQ ER EE SZ ET FK FO FJ FI FR GF
- Enabled: false
+   PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM VA HN HK HU IS IN ID
- AllowRedirects: null
+   IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO
-
+   MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ

Mirror 'test' edited successfully
root@centos:~# mirrorbits show test
Name: test
HttpURL: http://localhost/
RsyncURL: ""
FtpURL: ""
SponsorName: ""
SponsorURL: ""
SponsorLogoURL: ""
AdminName: ""
AdminEmail: ""
CustomData: ""
ContinentOnly: false
CountryOnly: false
ASOnly: false
Score: 0
Latitude: 0
Longitude: 0
ContinentCode: ""
CountryCodes: AF AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ
  BM BT BO BQ BA BW BV BR IO BN BG BF BI CV KH CM CA KY CF TD CL CN CX CC CO KM CD
  CG CK CR HR CU CW CY CZ CI DK DJ DM DO EC EG SV GQ ER EE SZ ET FK FO FJ FI FR GF
  PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM VA HN HK HU IS IN ID
  IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO
  MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ
  NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA MK RO RU RW RE BL
  SH KN LC MF PM VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK SD SR
  SJ SE CH SY TW TJ TZ TH TL TG TK TO TT TN TR TM TC TV UG UA AE GB UM US UY UZ VU
  VE VN VG VI WF EH YE ZM ZW AX
ExcludedCountryCodes: ""
ASNum: 0
Enabled: true
AllowRedirects: null

Comment:

root@centos:~#

there is no + Enabled: true in output!

loanfedora commented 2 years ago

something todo with https://github.com/etix/mirrorbits/blob/33000b73aba3b6fffc24d459017431f6f7f2af88/rpc/rpc.go#L322 @etix ?

etix commented 2 years ago

Usually, the easiest way to enable (or disable) a mirror is to use mirrorbits enable <mirror> and not edit but I agree this should probably appear in the diff.

loanfedora commented 2 years ago

enable was demo other fields also no show too

it crop output! diff incomplete!!! diff not easy to read too without grouping!!!

fix disable wordwrap @etix ?

etix commented 2 years ago

Not sure word wrap is the issue there.