Unverified Commit c695494d authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Merge branch 'main' into motis

parents e5da62bc 3322ca23
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -82,6 +82,12 @@ Please open an issue on <https://github.com/derf/travelynx/issues> or send a
mail to derf+travelynx@finalrewind.org if there is anything missing or
ambiguous in this setup manual.

Note that Deutsche Bahn have put parts of their API behind an IP reputation
filter. In general, checkins with the bahn.de backend will only be possible if
travelynx is accessing it from a residential (non-server) IP range.  See the
dbris bahn.de proxy / proxies setting in `example/travelynx.conf` for
workarounds.

Updating
---

+21 −21
Original line number Diff line number Diff line
@@ -1662,15 +1662,15 @@ DISTRIBUTIONS
      Net::Domain 1.05
      Net::SMTP 1.28
      Test::More 0
  Math-Polygon-1.10
    pathname: M/MA/MARKOV/Math-Polygon-1.10.tar.gz
  Math-Polygon-1.11
    pathname: M/MA/MARKOV/Math-Polygon-1.11.tar.gz
    provides:
      Math::Polygon 1.10
      Math::Polygon::Calc 1.10
      Math::Polygon::Clip 1.10
      Math::Polygon::Convex 1.10
      Math::Polygon::Surface 1.10
      Math::Polygon::Transform 1.10
      Math::Polygon 1.11
      Math::Polygon::Calc 1.11
      Math::Polygon::Clip 1.11
      Math::Polygon::Convex 1.11
      Math::Polygon::Surface 1.11
      Math::Polygon::Transform 1.11
    requirements:
      ExtUtils::MakeMaker 0
      Math::Trig 0
@@ -1774,10 +1774,10 @@ DISTRIBUTIONS
      if 0
      perl 5.006
      strict 0
  Module-Runtime-0.017
    pathname: H/HA/HAARG/Module-Runtime-0.017.tar.gz
  Module-Runtime-0.018
    pathname: H/HA/HAARG/Module-Runtime-0.018.tar.gz
    provides:
      Module::Runtime 0.017
      Module::Runtime 0.018
    requirements:
      ExtUtils::MakeMaker 0
      perl 5.006000
@@ -2544,17 +2544,17 @@ DISTRIBUTIONS
      TimeDate 1.21
    requirements:
      ExtUtils::MakeMaker 0
  Travel-Status-DE-DBRIS-0.10
    pathname: D/DE/DERF/Travel-Status-DE-DBRIS-0.10.tar.gz
  Travel-Status-DE-DBRIS-0.11
    pathname: D/DE/DERF/Travel-Status-DE-DBRIS-0.11.tar.gz
    provides:
      Travel::Status::DE::DBRIS 0.10
      Travel::Status::DE::DBRIS::Formation 0.10
      Travel::Status::DE::DBRIS::Formation::Carriage 0.10
      Travel::Status::DE::DBRIS::Formation::Group 0.10
      Travel::Status::DE::DBRIS::Formation::Sector 0.10
      Travel::Status::DE::DBRIS::Journey 0.10
      Travel::Status::DE::DBRIS::JourneyAtStop 0.10
      Travel::Status::DE::DBRIS::Location 0.10
      Travel::Status::DE::DBRIS 0.11
      Travel::Status::DE::DBRIS::Formation 0.11
      Travel::Status::DE::DBRIS::Formation::Carriage 0.11
      Travel::Status::DE::DBRIS::Formation::Group 0.11
      Travel::Status::DE::DBRIS::Formation::Sector 0.11
      Travel::Status::DE::DBRIS::Journey 0.11
      Travel::Status::DE::DBRIS::JourneyAtStop 0.11
      Travel::Status::DE::DBRIS::Location 0.11
    requirements:
      Carp 0
      Class::Accessor 0.16
+19 −2
Original line number Diff line number Diff line
@@ -35,14 +35,31 @@
		password => die("Changeme!"),
	},

	# Settings specific to the DBRIS bahn.de backend.
	# Their journey endpoint (which is required for checkins) is behind an IP
	# reputation filter, denying requests from most non-residential IP ranges.
	# If needed, you can specify either a single SOCKS proxy or a set of
	# SOCKS proxies here, and thus work around that limitation. If multiple
	# proxies are specified, travelynx will choose a random one for each
	# request. Note that DBRIS bahn.de requests to non-journey endpoints
	# (such as the departure board) are always sent directly and not passed
	# through the proxy / proxies specified here.
	# "proxies" takes precedence over "proxy".
	dbris => {
		'bahn.de' => {
			# proxy => 'socks://127.0.0.1:18080', # <- either this
			# proxies => ['socks://127.0.0.1:18080', 'socks://127.0.0.1:18081'],
		},
	},

	# Settings specific to HAFAS backends.
	# For instance, the PKP backend is hidden behind a GeoIP filter, hence
	# travelynx only supports it if travelynx.conf either indicates that it
	# is reachable or specifies a proxy.
	hafas => {
		PKP => {
			# geoip_ok => 1,          # <- EITHER THIS
			# proxy => 'socks://...', # <- OR THIS
			# geoip_ok => 1,          # <- either this
			# proxy => 'socks://...', # <- or this
		},
	},

+67 −31
Original line number Diff line number Diff line
@@ -1258,7 +1258,7 @@ sub startup {
								if (@unknown_stations) {
									$self->app->log->warn(
										sprintf(
'Route of %s %s (%s -> %s) contains unknown stations: %s',
'IRIS: Route of %s %s (%s -> %s) contains unknown stations: %s',
											$train->type,
											$train->train_no,
											$train->origin,
@@ -1625,34 +1625,51 @@ sub startup {
						my $data      = {};
						my $user_data = {};

						my $wr;
						eval {
							$wr
							  = Travel::Status::DE::DBRIS::Formation->new(
								json => $wagonorder );
						};

						if (    $opt{is_departure}
							and $wr
							and not exists $wagonorder->{error} )
						{
							my $dt
							  = $opt{datetime}->clone->set_time_zone('UTC');
							$data->{wagonorder_dep}   = $wagonorder;
							$data->{wagonorder_param} = {
								time      => $dt->rfc3339 =~ s{(?=Z)}{.000}r,
								number    => $opt{train_no},
								evaNumber => $opt{eva},
								administrationId => 80,
								date             => $dt->strftime('%Y-%m-%d'),
								category         => $opt{train_type},
							};
							$user_data->{wagongroups} = [];
							for my $group ( @{ $wagonorder->{groups} // [] } ) {
							for my $group ( $wr->groups ) {
								my @wagons;
								for my $wagon ( @{ $group->{vehicles} // [] } )
								{
								for my $wagon ( $group->carriages ) {
									push(
										@wagons,
										{
											id     => $wagon->{vehicleID},
											number => $wagon
											  ->{wagonIdentificationNumber},
											type =>
											  $wagon->{type}{constructionType},
											id     => $wagon->uic_id,
											number => $wagon->number,
											type   => $wagon->type,
										}
									);
								}
								push(
									@{ $user_data->{wagongroups} },
									{
										name => $group->{name},
										to   => $group->{transport}{destination}
										  {name},
										type   => $group->{transport}{category},
										no     => $group->{transport}{number},
										name        => $group->name,
										desc        => $group->desc_short,
										description => $group->description,
										designation => $group->designation,
										to          => $group->destination,
										type        => $group->train_type,
										no          => $group->train_no,
										wagons      => [@wagons],
									}
								);
@@ -1932,7 +1949,15 @@ sub startup {
			$ret =~ s{[{]tt[}]}{$opt{tt}}g;
			$ret =~ s{[{]tn[}]}{$opt{tn}}g;
			$ret =~ s{[{]id[}]}{$opt{id}}g;
			$ret =~ s{[{]dbris[}]}{$opt{dbris}}g;
			$ret =~ s{[{]hafas[}]}{$opt{hafas}}g;

			if ( $opt{id} and not $opt{is_iris} ) {
				$ret =~ s{[{]id_or_tttn[}]}{$opt{id}}g;
			}
			else {
				$ret =~ s{[{]id_or_tttn[}]}{$opt{tt}$opt{tn}}g;
			}
			return $ret;
		}
	);
@@ -2033,6 +2058,7 @@ sub startup {
				uid             => $uid,
				db              => $db,
				with_data       => 1,
				with_polyline   => 1,
				with_timestamps => 1,
				with_visibility => 1,
				postprocess     => 1,
@@ -2467,12 +2493,12 @@ sub startup {

			my @stations = uniq_by { $_->{name} } map {
				{
					name   => $_->{to_name},
					latlon => $_->{to_latlon}
					name   => $_->{to_name}   // $_->{arr_name},
					latlon => $_->{to_latlon} // $_->{arr_latlon},
				},
				  {
					name   => $_->{from_name},
					latlon => $_->{from_latlon}
					name   => $_->{from_name}   // $_->{dep_name},
					latlon => $_->{from_latlon} // $_->{dep_latlon}
				  }
			} @journeys;

@@ -2497,8 +2523,8 @@ sub startup {

			for my $journey (@polyline_journeys) {
				my @polyline = @{ $journey->{polyline} };
				my $from_eva = $journey->{from_eva};
				my $to_eva   = $journey->{to_eva};
				my $from_eva = $journey->{from_eva} // $journey->{dep_eva};
				my $to_eva   = $journey->{to_eva}   // $journey->{arr_eva};

				my $from_index
				  = first_index { $_->[2] and $_->[2] == $from_eva } @polyline;
@@ -2534,7 +2560,7 @@ sub startup {
					or $to_index == -1 )
				{
					# Fall back to route
					delete $journey->{polyline};
					push( @beeline_journeys, $journey );
					next;
				}

@@ -2556,6 +2582,9 @@ sub startup {
				  . ( $to_index - $from_index );
				$seen{$key} = 1;

				if ( $from_index > $to_index ) {
					( $to_index, $from_index ) = ( $from_index, $to_index );
				}
				@polyline = @polyline[ $from_index .. $to_index ];
				my @polyline_coords;
				for my $coord (@polyline) {
@@ -2569,13 +2598,19 @@ sub startup {
				my @route = @{ $journey->{route} };

				my $from_index = first_index {
					( $_->[1] and $_->[1] == $journey->{from_eva} )
					  or $_->[0] eq $journey->{from_name}
					(         $_->[1]
						  and $_->[1]
						  == ( $journey->{from_eva} // $journey->{dep_eva} ) )
					  or $_->[0] eq
					  ( $journey->{from_name} // $journey->{dep_name} )
				}
				@route;
				my $to_index = first_index {
					( $_->[1] and $_->[1] == $journey->{to_eva} )
					  or $_->[0] eq $journey->{to_name}
					(         $_->[1]
						  and $_->[1]
						  == ( $journey->{to_eva} // $journey->{arr_eva} ) )
					  or $_->[0] eq
					  ( $journey->{to_name} // $journey->{arr_name} )
				}
				@route;

@@ -2583,7 +2618,7 @@ sub startup {
					my $rename = $self->app->renamed_station;
					$from_index = first_index {
						( $rename->{ $_->[0] } // $_->[0] ) eq
						  $journey->{from_name}
						  ( $journey->{from_name} // $journey->{dep_name} )
					}
					@route;
				}
@@ -2591,7 +2626,7 @@ sub startup {
					my $rename = $self->app->renamed_station;
					$to_index = first_index {
						( $rename->{ $_->[0] }  // $_->[0] ) eq
						  $journey->{to_name}
						  ( $journey->{to_name} // $journey->{arr_name} )
					}
					@route;
				}
@@ -2614,7 +2649,8 @@ sub startup {
				# and entered manually (-> beeline also shown on map, typically
				# significantly differs from detailed route) -- unless the user
				# sets include_manual, of course.
				if (    $journey->{edited} & 0x0010
				if (    $journey->{edited}
					and $journey->{edited} & 0x0010
					and @route <= 2
					and not $include_manual )
				{
+12 −0
Original line number Diff line number Diff line
@@ -135,6 +135,18 @@ sub run {
									$found_arr->eva );
							}
						}
						if ( $found_arr and $found_arr->is_cancelled ) {

							# check out (adds a cancelled journey and resets journey state
							# to destination selection)
							$self->app->checkout_p(
								station => $arr,
								force   => 0,
								dep_eva => $dep,
								arr_eva => $arr,
								uid     => $uid
							)->wait;
						}
					}
				)->catch(
					sub {
Loading